commit_title
stringlengths 13
124
| commit_body
stringlengths 0
1.9k
| release_summary
stringclasses 52
values | changes_summary
stringlengths 1
758
| release_affected_domains
stringclasses 33
values | release_affected_drivers
stringclasses 51
values | domain_of_changes
stringlengths 2
571
| language_set
stringclasses 983
values | diffstat_files
int64 1
300
| diffstat_insertions
int64 0
309k
| diffstat_deletions
int64 0
168k
| commit_diff
stringlengths 92
23.4M
| category
stringclasses 108
values | commit_hash
stringlengths 34
40
| related_people
stringlengths 0
370
| domain
stringclasses 21
values | subdomain
stringclasses 241
values | leaf_module
stringlengths 0
912
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
phy: nxp-c45-tja11xx: add interrupt support
|
added .config_intr and .handle_interrupt callbacks.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add interrupt support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['phy ', 'nxp-c45-tja11xx']
|
['c']
| 1
| 33
| 0
|
--- diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c +#define vend1_phy_irq_ack 0x80a0 +#define vend1_phy_irq_en 0x80a1 +#define vend1_phy_irq_status 0x80a2 +#define phy_irq_link_event bit(1) + +static int nxp_c45_config_intr(struct phy_device *phydev) +{ + if (phydev->interrupts == phy_interrupt_enabled) + return phy_set_bits_mmd(phydev, mdio_mmd_vend1, + vend1_phy_irq_en, phy_irq_link_event); + else + return phy_clear_bits_mmd(phydev, mdio_mmd_vend1, + vend1_phy_irq_en, phy_irq_link_event); +} + +static irqreturn_t nxp_c45_handle_interrupt(struct phy_device *phydev) +{ + irqreturn_t ret = irq_none; + int irq; + + irq = phy_read_mmd(phydev, mdio_mmd_vend1, vend1_phy_irq_status); + if (irq & phy_irq_link_event) { + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_phy_irq_ack, + phy_irq_link_event); + phy_trigger_machine(phydev); + ret = irq_handled; + } + + return ret; +} + + .config_intr = nxp_c45_config_intr, + .handle_interrupt = nxp_c45_handle_interrupt,
|
Networking
|
b2f0ca00e6b34bd57c9298a869ea133699e8ec39
|
radu pirea nxp oss
|
drivers
|
net
|
phy
|
phy: nxp-c45: add driver for tja1103
|
add driver for tja1103 driver and for future nxp c45 phys.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add driver for tja1103
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['phy ', 'nxp-c45']
|
['kconfig', 'maintainers', 'c', 'makefile']
| 4
| 601
| 0
|
--- diff --git a/maintainers b/maintainers --- a/maintainers +++ b/maintainers +nxp c45 tja11xx phy driver +m: radu pirea <radu-nicolae.pirea@oss.nxp.com> +l: netdev@vger.kernel.org +s: maintained +f: drivers/net/phy/nxp-c45-tja11xx.c + diff --git a/drivers/net/phy/kconfig b/drivers/net/phy/kconfig --- a/drivers/net/phy/kconfig +++ b/drivers/net/phy/kconfig +config nxp_c45_tja11xx_phy + tristate "nxp c45 tja11xx phys" + help + enable support for nxp c45 tja11xx phys. + currently supports only the tja1103 phy. + diff --git a/drivers/net/phy/makefile b/drivers/net/phy/makefile --- a/drivers/net/phy/makefile +++ b/drivers/net/phy/makefile +obj-$(config_nxp_c45_tja11xx_phy) += nxp-c45-tja11xx.o diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c --- /dev/null +++ b/drivers/net/phy/nxp-c45-tja11xx.c +// spdx-license-identifier: gpl-2.0 +/* nxp c45 phy driver + * copyright (c) 2021 nxp + * author: radu pirea <radu-nicolae.pirea@oss.nxp.com> + */ + +#include <linux/delay.h> +#include <linux/ethtool.h> +#include <linux/ethtool_netlink.h> +#include <linux/kernel.h> +#include <linux/mii.h> +#include <linux/module.h> +#include <linux/phy.h> +#include <linux/processor.h> +#include <linux/property.h> + +#define phy_id_tja_1103 0x001bb010 + +#define pmapmd_b100t1_pmapmd_ctl 0x0834 +#define b100t1_pmapmd_config_en bit(15) +#define b100t1_pmapmd_master bit(14) +#define master_mode (b100t1_pmapmd_config_en | \ + b100t1_pmapmd_master) +#define slave_mode (b100t1_pmapmd_config_en) + +#define vend1_device_control 0x0040 +#define device_control_reset bit(15) +#define device_control_config_global_en bit(14) +#define device_control_config_all_en bit(13) + +#define vend1_phy_control 0x8100 +#define phy_config_en bit(14) +#define phy_start_op bit(0) + +#define vend1_phy_config 0x8108 +#define phy_config_auto bit(0) + +#define vend1_signal_quality 0x8320 +#define sqi_valid bit(14) +#define sqi_mask genmask(2, 0) +#define max_sqi sqi_mask + +#define vend1_cable_test 0x8330 +#define cable_test_enable bit(15) +#define cable_test_start bit(14) +#define cable_test_valid bit(13) +#define cable_test_ok 0x00 +#define cable_test_shorted 0x01 +#define cable_test_open 0x02 +#define cable_test_unknown 0x07 + +#define vend1_port_control 0x8040 +#define port_control_en bit(14) + +#define vend1_port_infra_control 0xac00 +#define port_infra_control_en bit(14) + +#define vend1_rxid 0xafcc +#define vend1_txid 0xafcd +#define id_enable bit(15) + +#define vend1_abilities 0xafc4 +#define rgmii_id_ability bit(15) +#define rgmii_ability bit(14) +#define rmii_ability bit(10) +#define revmii_ability bit(9) +#define mii_ability bit(8) +#define sgmii_ability bit(0) + +#define vend1_mii_basic_config 0xafc6 +#define mii_basic_config_rev bit(8) +#define mii_basic_config_sgmii 0x9 +#define mii_basic_config_rgmii 0x7 +#define mii_basic_config_rmii 0x5 +#define mii_basic_config_mii 0x4 + +#define vend1_symbol_error_counter 0x8350 +#define vend1_link_drop_counter 0x8352 +#define vend1_link_losses_and_failures 0x8353 +#define vend1_r_good_frame_cnt 0xa950 +#define vend1_r_bad_frame_cnt 0xa952 +#define vend1_r_rxer_frame_cnt 0xa954 +#define vend1_rx_preamble_count 0xafce +#define vend1_tx_preamble_count 0xafcf +#define vend1_rx_ipg_length 0xafd0 +#define vend1_tx_ipg_length 0xafd1 +#define counter_en bit(15) + +#define rgmii_period_ps 8000u +#define ps_per_degree div_u64(rgmii_period_ps, 360) +#define min_id_ps 1644u +#define max_id_ps 2260u +#define default_id_ps 2000u + +struct nxp_c45_phy { + u32 tx_delay; + u32 rx_delay; +}; + +struct nxp_c45_phy_stats { + const char *name; + u8 mmd; + u16 reg; + u8 off; + u16 mask; +}; + +static const struct nxp_c45_phy_stats nxp_c45_hw_stats[] = { + { "phy_symbol_error_cnt", mdio_mmd_vend1, + vend1_symbol_error_counter, 0, genmask(15, 0) }, + { "phy_link_status_drop_cnt", mdio_mmd_vend1, + vend1_link_drop_counter, 8, genmask(13, 8) }, + { "phy_link_availability_drop_cnt", mdio_mmd_vend1, + vend1_link_drop_counter, 0, genmask(5, 0) }, + { "phy_link_loss_cnt", mdio_mmd_vend1, + vend1_link_losses_and_failures, 10, genmask(15, 10) }, + { "phy_link_failure_cnt", mdio_mmd_vend1, + vend1_link_losses_and_failures, 0, genmask(9, 0) }, + { "r_good_frame_cnt", mdio_mmd_vend1, + vend1_r_good_frame_cnt, 0, genmask(15, 0) }, + { "r_bad_frame_cnt", mdio_mmd_vend1, + vend1_r_bad_frame_cnt, 0, genmask(15, 0) }, + { "r_rxer_frame_cnt", mdio_mmd_vend1, + vend1_r_rxer_frame_cnt, 0, genmask(15, 0) }, + { "rx_preamble_count", mdio_mmd_vend1, + vend1_rx_preamble_count, 0, genmask(5, 0) }, + { "tx_preamble_count", mdio_mmd_vend1, + vend1_tx_preamble_count, 0, genmask(5, 0) }, + { "rx_ipg_length", mdio_mmd_vend1, + vend1_rx_ipg_length, 0, genmask(8, 0) }, + { "tx_ipg_length", mdio_mmd_vend1, + vend1_tx_ipg_length, 0, genmask(8, 0) }, +}; + +static int nxp_c45_get_sset_count(struct phy_device *phydev) +{ + return array_size(nxp_c45_hw_stats); +} + +static void nxp_c45_get_strings(struct phy_device *phydev, u8 *data) +{ + size_t i; + + for (i = 0; i < array_size(nxp_c45_hw_stats); i++) { + strncpy(data + i * eth_gstring_len, + nxp_c45_hw_stats[i].name, eth_gstring_len); + } +} + +static void nxp_c45_get_stats(struct phy_device *phydev, + struct ethtool_stats *stats, u64 *data) +{ + size_t i; + int ret; + + for (i = 0; i < array_size(nxp_c45_hw_stats); i++) { + ret = phy_read_mmd(phydev, nxp_c45_hw_stats[i].mmd, + nxp_c45_hw_stats[i].reg); + if (ret < 0) { + data[i] = u64_max; + } else { + data[i] = ret & nxp_c45_hw_stats[i].mask; + data[i] >>= nxp_c45_hw_stats[i].off; + } + } +} + +static int nxp_c45_config_enable(struct phy_device *phydev) +{ + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_device_control, + device_control_config_global_en | + device_control_config_all_en); + usleep_range(400, 450); + + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_port_control, + port_control_en); + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_phy_control, + phy_config_en); + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_port_infra_control, + port_infra_control_en); + + return 0; +} + +static int nxp_c45_start_op(struct phy_device *phydev) +{ + return phy_set_bits_mmd(phydev, mdio_mmd_vend1, vend1_phy_control, + phy_start_op); +} + +static int nxp_c45_soft_reset(struct phy_device *phydev) +{ + int ret; + + ret = phy_write_mmd(phydev, mdio_mmd_vend1, vend1_device_control, + device_control_reset); + if (ret) + return ret; + + return phy_read_mmd_poll_timeout(phydev, mdio_mmd_vend1, + vend1_device_control, ret, + !(ret & device_control_reset), 20000, + 240000, false); +} + +static int nxp_c45_cable_test_start(struct phy_device *phydev) +{ + return phy_write_mmd(phydev, mdio_mmd_vend1, vend1_cable_test, + cable_test_enable | cable_test_start); +} + +static int nxp_c45_cable_test_get_status(struct phy_device *phydev, + bool *finished) +{ + int ret; + u8 cable_test_result; + + ret = phy_read_mmd(phydev, mdio_mmd_vend1, vend1_cable_test); + if (!(ret & cable_test_valid)) { + *finished = false; + return 0; + } + + *finished = true; + cable_test_result = ret & genmask(2, 0); + + switch (cable_test_result) { + case cable_test_ok: + ethnl_cable_test_result(phydev, ethtool_a_cable_pair_a, + ethtool_a_cable_result_code_ok); + break; + case cable_test_shorted: + ethnl_cable_test_result(phydev, ethtool_a_cable_pair_a, + ethtool_a_cable_result_code_same_short); + break; + case cable_test_open: + ethnl_cable_test_result(phydev, ethtool_a_cable_pair_a, + ethtool_a_cable_result_code_open); + break; + default: + ethnl_cable_test_result(phydev, ethtool_a_cable_pair_a, + ethtool_a_cable_result_code_unspec); + } + + phy_clear_bits_mmd(phydev, mdio_mmd_vend1, vend1_cable_test, + cable_test_enable); + + return nxp_c45_start_op(phydev); +} + +static int nxp_c45_setup_master_slave(struct phy_device *phydev) +{ + switch (phydev->master_slave_set) { + case master_slave_cfg_master_force: + case master_slave_cfg_master_preferred: + phy_write_mmd(phydev, mdio_mmd_pmapmd, pmapmd_b100t1_pmapmd_ctl, + master_mode); + break; + case master_slave_cfg_slave_preferred: + case master_slave_cfg_slave_force: + phy_write_mmd(phydev, mdio_mmd_pmapmd, pmapmd_b100t1_pmapmd_ctl, + slave_mode); + break; + case master_slave_cfg_unknown: + case master_slave_cfg_unsupported: + return 0; + default: + phydev_warn(phydev, "unsupported master/slave mode "); + return -eopnotsupp; + } + + return 0; +} + +static int nxp_c45_read_master_slave(struct phy_device *phydev) +{ + int reg; + + phydev->master_slave_get = master_slave_cfg_unknown; + phydev->master_slave_state = master_slave_state_unknown; + + reg = phy_read_mmd(phydev, mdio_mmd_pmapmd, pmapmd_b100t1_pmapmd_ctl); + if (reg < 0) + return reg; + + if (reg & b100t1_pmapmd_master) { + phydev->master_slave_get = master_slave_cfg_master_force; + phydev->master_slave_state = master_slave_state_master; + } else { + phydev->master_slave_get = master_slave_cfg_slave_force; + phydev->master_slave_state = master_slave_state_slave; + } + + return 0; +} + +static int nxp_c45_config_aneg(struct phy_device *phydev) +{ + return nxp_c45_setup_master_slave(phydev); +} + +static int nxp_c45_read_status(struct phy_device *phydev) +{ + int ret; + + ret = genphy_c45_read_status(phydev); + if (ret) + return ret; + + ret = nxp_c45_read_master_slave(phydev); + if (ret) + return ret; + + return 0; +} + +static int nxp_c45_get_sqi(struct phy_device *phydev) +{ + int reg; + + reg = phy_read_mmd(phydev, mdio_mmd_vend1, vend1_signal_quality); + if (!(reg & sqi_valid)) + return -einval; + + reg &= sqi_mask; + + return reg; +} + +static int nxp_c45_get_sqi_max(struct phy_device *phydev) +{ + return max_sqi; +} + +static int nxp_c45_check_delay(struct phy_device *phydev, u32 delay) +{ + if (delay < min_id_ps) { + phydev_err(phydev, "delay value smaller than %u ", min_id_ps); + return -einval; + } + + if (delay > max_id_ps) { + phydev_err(phydev, "delay value higher than %u ", max_id_ps); + return -einval; + } + + return 0; +} + +static u64 nxp_c45_get_phase_shift(u64 phase_offset_raw) +{ + /* the delay in degree phase is 73.8 + phase_offset_raw * 0.9. + * to avoid floating point operations we'll multiply by 10 + * and get 1 decimal point precision. + */ + phase_offset_raw *= 10; + phase_offset_raw -= phase_offset_raw; + return div_u64(phase_offset_raw, 9); +} + +static void nxp_c45_disable_delays(struct phy_device *phydev) +{ + phy_clear_bits_mmd(phydev, mdio_mmd_vend1, vend1_txid, id_enable); + phy_clear_bits_mmd(phydev, mdio_mmd_vend1, vend1_rxid, id_enable); +} + +static void nxp_c45_set_delays(struct phy_device *phydev) +{ + struct nxp_c45_phy *priv = phydev->priv; + u64 tx_delay = priv->tx_delay; + u64 rx_delay = priv->rx_delay; + u64 degree; + + if (phydev->interface == phy_interface_mode_rgmii_id || + phydev->interface == phy_interface_mode_rgmii_txid) { + degree = div_u64(tx_delay, ps_per_degree); + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_txid, + id_enable | nxp_c45_get_phase_shift(degree)); + } else { + phy_clear_bits_mmd(phydev, mdio_mmd_vend1, vend1_txid, + id_enable); + } + + if (phydev->interface == phy_interface_mode_rgmii_id || + phydev->interface == phy_interface_mode_rgmii_rxid) { + degree = div_u64(rx_delay, ps_per_degree); + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_rxid, + id_enable | nxp_c45_get_phase_shift(degree)); + } else { + phy_clear_bits_mmd(phydev, mdio_mmd_vend1, vend1_rxid, + id_enable); + } +} + +static int nxp_c45_get_delays(struct phy_device *phydev) +{ + struct nxp_c45_phy *priv = phydev->priv; + int ret; + + if (phydev->interface == phy_interface_mode_rgmii_id || + phydev->interface == phy_interface_mode_rgmii_txid) { + ret = device_property_read_u32(&phydev->mdio.dev, + "tx-internal-delay-ps", + &priv->tx_delay); + if (ret) + priv->tx_delay = default_id_ps; + + ret = nxp_c45_check_delay(phydev, priv->tx_delay); + if (ret) { + phydev_err(phydev, + "tx-internal-delay-ps invalid value "); + return ret; + } + } + + if (phydev->interface == phy_interface_mode_rgmii_id || + phydev->interface == phy_interface_mode_rgmii_rxid) { + ret = device_property_read_u32(&phydev->mdio.dev, + "rx-internal-delay-ps", + &priv->rx_delay); + if (ret) + priv->rx_delay = default_id_ps; + + ret = nxp_c45_check_delay(phydev, priv->rx_delay); + if (ret) { + phydev_err(phydev, + "rx-internal-delay-ps invalid value "); + return ret; + } + } + + return 0; +} + +static int nxp_c45_set_phy_mode(struct phy_device *phydev) +{ + int ret; + + ret = phy_read_mmd(phydev, mdio_mmd_vend1, vend1_abilities); + phydev_dbg(phydev, "clause 45 managed phy abilities 0x%x ", ret); + + switch (phydev->interface) { + case phy_interface_mode_rgmii: + if (!(ret & rgmii_ability)) { + phydev_err(phydev, "rgmii mode not supported "); + return -einval; + } + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_mii_basic_config, + mii_basic_config_rgmii); + nxp_c45_disable_delays(phydev); + break; + case phy_interface_mode_rgmii_id: + case phy_interface_mode_rgmii_txid: + case phy_interface_mode_rgmii_rxid: + if (!(ret & rgmii_id_ability)) { + phydev_err(phydev, "rgmii-id, rgmii-txid, rgmii-rxid modes are not supported "); + return -einval; + } + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_mii_basic_config, + mii_basic_config_rgmii); + ret = nxp_c45_get_delays(phydev); + if (ret) + return ret; + + nxp_c45_set_delays(phydev); + break; + case phy_interface_mode_mii: + if (!(ret & mii_ability)) { + phydev_err(phydev, "mii mode not supported "); + return -einval; + } + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_mii_basic_config, + mii_basic_config_mii); + break; + case phy_interface_mode_revmii: + if (!(ret & revmii_ability)) { + phydev_err(phydev, "rev-mii mode not supported "); + return -einval; + } + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_mii_basic_config, + mii_basic_config_mii | mii_basic_config_rev); + break; + case phy_interface_mode_rmii: + if (!(ret & rmii_ability)) { + phydev_err(phydev, "rmii mode not supported "); + return -einval; + } + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_mii_basic_config, + mii_basic_config_rmii); + break; + case phy_interface_mode_sgmii: + if (!(ret & sgmii_ability)) { + phydev_err(phydev, "sgmii mode not supported "); + return -einval; + } + phy_write_mmd(phydev, mdio_mmd_vend1, vend1_mii_basic_config, + mii_basic_config_sgmii); + break; + case phy_interface_mode_internal: + break; + default: + return -einval; + } + + return 0; +} + +static int nxp_c45_config_init(struct phy_device *phydev) +{ + int ret; + + ret = nxp_c45_config_enable(phydev); + if (ret) { + phydev_err(phydev, "failed to enable config "); + return ret; + } + + phy_set_bits_mmd(phydev, mdio_mmd_vend1, vend1_phy_config, + phy_config_auto); + + phy_set_bits_mmd(phydev, mdio_mmd_vend1, vend1_link_drop_counter, + counter_en); + phy_set_bits_mmd(phydev, mdio_mmd_vend1, vend1_rx_preamble_count, + counter_en); + phy_set_bits_mmd(phydev, mdio_mmd_vend1, vend1_tx_preamble_count, + counter_en); + phy_set_bits_mmd(phydev, mdio_mmd_vend1, vend1_rx_ipg_length, + counter_en); + phy_set_bits_mmd(phydev, mdio_mmd_vend1, vend1_tx_ipg_length, + counter_en); + + ret = nxp_c45_set_phy_mode(phydev); + if (ret) + return ret; + + phydev->autoneg = autoneg_disable; + + return nxp_c45_start_op(phydev); +} + +static int nxp_c45_probe(struct phy_device *phydev) +{ + struct nxp_c45_phy *priv; + + priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), gfp_kernel); + if (!priv) + return -enomem; + + phydev->priv = priv; + + return 0; +} + +static struct phy_driver nxp_c45_driver[] = { + { + phy_id_match_model(phy_id_tja_1103), + .name = "nxp c45 tja1103", + .features = phy_basic_t1_features, + .probe = nxp_c45_probe, + .soft_reset = nxp_c45_soft_reset, + .config_aneg = nxp_c45_config_aneg, + .config_init = nxp_c45_config_init, + .read_status = nxp_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = genphy_c45_pma_resume, + .get_sset_count = nxp_c45_get_sset_count, + .get_strings = nxp_c45_get_strings, + .get_stats = nxp_c45_get_stats, + .cable_test_start = nxp_c45_cable_test_start, + .cable_test_get_status = nxp_c45_cable_test_get_status, + .set_loopback = genphy_c45_loopback, + .get_sqi = nxp_c45_get_sqi, + .get_sqi_max = nxp_c45_get_sqi_max, + }, +}; + +module_phy_driver(nxp_c45_driver); + +static struct mdio_device_id __maybe_unused nxp_c45_tbl[] = { + { phy_id_match_model(phy_id_tja_1103) }, + { /*sentinel*/ }, +}; + +module_device_table(mdio, nxp_c45_tbl); + +module_author("radu pirea <radu-nicolae.pirea@oss.nxp.com>"); +module_description("nxp c45 phy driver"); +module_license("gpl v2");
|
Networking
|
b050f2f15e04f0416118f689f740fda466a47752
|
radu pirea nxp oss
|
drivers
|
net
|
phy
|
phy: sfp: add netlink sfp support to generic sfp code
|
the new netlink api for reading sfp data requires a new op to be implemented. the idea of the new netlink sfp code is that userspace is responsible to parsing the eeprom data and requesting pages, rather than have the kernel decide what pages are interesting and returning them. this allows greater flexibility for newer formats.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add netlink sfp support to generic sfp code
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['phy ', 'sfp']
|
['h', 'c']
| 4
| 58
| 0
|
--- diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c --- a/drivers/net/phy/sfp-bus.c +++ b/drivers/net/phy/sfp-bus.c +/** + * sfp_get_module_eeprom_by_page() - read a page from the sfp module eeprom + * @bus: a pointer to the &struct sfp_bus structure for the sfp module + * @page: a &struct ethtool_module_eeprom + * @extack: extack for reporting problems + * + * read an eeprom page as specified by the supplied @page. see the + * documentation for &struct ethtool_module_eeprom for the page to be read. + * + * returns 0 on success or a negative errno number. more error + * information might be provided via extack + */ +int sfp_get_module_eeprom_by_page(struct sfp_bus *bus, + const struct ethtool_module_eeprom *page, + struct netlink_ext_ack *extack) +{ + return bus->socket_ops->module_eeprom_by_page(bus->sfp, page, extack); +} +export_symbol_gpl(sfp_get_module_eeprom_by_page); + diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c +static int sfp_module_eeprom_by_page(struct sfp *sfp, + const struct ethtool_module_eeprom *page, + struct netlink_ext_ack *extack) +{ + if (page->bank) { + nl_set_err_msg(extack, "banks not supported"); + return -eopnotsupp; + } + + if (page->page) { + nl_set_err_msg(extack, "only page 0 supported"); + return -eopnotsupp; + } + + if (page->i2c_address != 0x50 && + page->i2c_address != 0x51) { + nl_set_err_msg(extack, "only address 0x50 and 0x51 supported"); + return -eopnotsupp; + } + + return sfp_read(sfp, page->i2c_address == 0x51, page->offset, + page->data, page->length); +}; + + .module_eeprom_by_page = sfp_module_eeprom_by_page, diff --git a/drivers/net/phy/sfp.h b/drivers/net/phy/sfp.h --- a/drivers/net/phy/sfp.h +++ b/drivers/net/phy/sfp.h + int (*module_eeprom_by_page)(struct sfp *sfp, + const struct ethtool_module_eeprom *page, + struct netlink_ext_ack *extack); diff --git a/include/linux/sfp.h b/include/linux/sfp.h --- a/include/linux/sfp.h +++ b/include/linux/sfp.h +int sfp_get_module_eeprom_by_page(struct sfp_bus *bus, + const struct ethtool_module_eeprom *page, + struct netlink_ext_ack *extack); +static inline int sfp_get_module_eeprom_by_page(struct sfp_bus *bus, + const struct ethtool_module_eeprom *page, + struct netlink_ext_ack *extack) +{ + return -eopnotsupp; +} +
|
Networking
|
d740513f05a24b1a46722325974223980f068728
|
andrew lunn
|
include
|
linux
|
phy
|
r8152: set inter fram gap time depending on speed
|
set the maximum inter frame gap time (144ns) for speed 10m/half and 100m/half. it improves the performance for those speeds. and, there is no effect for the other speeds.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
support new chips
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['r8152']
|
['c']
| 1
| 28
| 0
|
--- diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c +#define ifg_mask (bit(3) | bit(9) | bit(8)) +#define ifg_144ns bit(9) +#define ifg_96ns (bit(9) | bit(8)) +static void rtl_set_ifg(struct r8152 *tp, u16 speed) +{ + u32 ocp_data; + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_tcr1); + ocp_data &= ~ifg_mask; + if ((speed & (_10bps | _100bps)) && !(speed & full_dup)) { + ocp_data |= ifg_144ns; + ocp_write_word(tp, mcu_type_pla, pla_tcr1, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4); + ocp_data &= ~tx10midle_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4, ocp_data); + } else { + ocp_data |= ifg_96ns; + ocp_write_word(tp, mcu_type_pla, pla_tcr1, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4); + ocp_data |= tx10midle_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4, ocp_data); + } +} + + rtl_set_ifg(tp, rtl8152_get_speed(tp)); +
|
Networking
|
5133bcc7481528e36fff0a3b056601efb704fb32
|
hayes wang
|
drivers
|
net
|
usb
|
r8152: adjust rtl8152_check_firmware function
|
use bits operations to record and check the firmware.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
support new chips
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['r8152']
|
['c']
| 1
| 29
| 22
|
--- diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c +enum rtl8152_fw_flags { + fw_flags_usb = 0, + fw_flags_pla, + fw_flags_start, + fw_flags_stop, + fw_flags_nc, +}; + - struct fw_mac *pla = null, *usb = null; - struct fw_phy_patch_key *start = null; - struct fw_phy_nc *phy_nc = null; - struct fw_block *stop = null; + unsigned long fw_flags = 0; - if (pla) { + if (test_bit(fw_flags_pla, &fw_flags)) { - pla = (struct fw_mac *)block; - if (!rtl8152_is_fw_mac_ok(tp, pla)) { + if (!rtl8152_is_fw_mac_ok(tp, (struct fw_mac *)block)) { + __set_bit(fw_flags_pla, &fw_flags); - if (usb) { + if (test_bit(fw_flags_usb, &fw_flags)) { - usb = (struct fw_mac *)block; - if (!rtl8152_is_fw_mac_ok(tp, usb)) { + if (!rtl8152_is_fw_mac_ok(tp, (struct fw_mac *)block)) { + __set_bit(fw_flags_usb, &fw_flags); - if (start || phy_nc || stop) { + if (test_bit(fw_flags_start, &fw_flags) || + test_bit(fw_flags_nc, &fw_flags) || + test_bit(fw_flags_stop, &fw_flags)) { - if (__le32_to_cpu(block->length) != sizeof(*start)) { + if (__le32_to_cpu(block->length) != sizeof(struct fw_phy_patch_key)) { - - start = (struct fw_phy_patch_key *)block; + __set_bit(fw_flags_start, &fw_flags); - if (stop || !start) { + if (test_bit(fw_flags_stop, &fw_flags) || + !test_bit(fw_flags_start, &fw_flags)) { - - stop = block; + __set_bit(fw_flags_stop, &fw_flags); - if (!start || stop) { + if (!test_bit(fw_flags_start, &fw_flags) || + test_bit(fw_flags_stop, &fw_flags)) { - if (phy_nc) { + if (test_bit(fw_flags_nc, &fw_flags)) { - phy_nc = (struct fw_phy_nc *)block; - if (!rtl8152_is_fw_phy_nc_ok(tp, phy_nc)) { + if (!rtl8152_is_fw_phy_nc_ok(tp, (struct fw_phy_nc *)block)) { + __set_bit(fw_flags_nc, &fw_flags); - if ((phy_nc || start) && !stop) { + if (test_bit(fw_flags_start, &fw_flags) && !test_bit(fw_flags_stop, &fw_flags)) {
|
Networking
|
a8a7be178e81a3d4b6972cbeb0ccd091ca2f9f89
|
hayes wang
|
drivers
|
net
|
usb
|
r8152: add help function to change mtu
|
the different chips may have different requests when changing mtu. therefore, add a new help function of rtl_ops to change mtu. besides, reset the tx/rx after changing mtu.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
support new chips
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['r8152']
|
['c']
| 1
| 31
| 22
|
--- diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c -#define rtl8153_max_packet 9216 /* 9k */ -#define rtl8153_max_mtu (rtl8153_max_packet - vlan_eth_hlen - \ - eth_fcs_len) -#define rx_reserved_size(x) ((x) + vlan_eth_hlen + eth_fcs_len + \ - sizeof(struct rx_desc) + rx_align) +#define mtu_to_size(m) ((m) + vlan_eth_hlen + eth_fcs_len) +#define size_to_mtu(s) ((s) - vlan_eth_hlen - eth_fcs_len) +#define rx_reserved_size(x) (mtu_to_size(x) + sizeof(struct rx_desc) + rx_align) + void (*change_mtu)(struct r8152 *tp); -#define rtl_limited_tso_size (agg_buf_sz - sizeof(struct tx_desc) - \ - vlan_eth_hlen - eth_fcs_len) +#define rtl_limited_tso_size (size_to_mtu(agg_buf_sz) - sizeof(struct tx_desc)) - struct net_device *netdev = tp->netdev; - - tp->tx_qlen = agg_buf_sz / (netdev->mtu + vlan_eth_hlen + eth_fcs_len + - sizeof(struct tx_desc)); + tp->tx_qlen = agg_buf_sz / (mtu_to_size(tp->netdev->mtu) + sizeof(struct tx_desc)); +static void rtl8153_change_mtu(struct r8152 *tp) +{ + ocp_write_word(tp, mcu_type_pla, pla_rms, mtu_to_size(tp->netdev->mtu)); + ocp_write_byte(tp, mcu_type_pla, pla_mtps, mtps_jumbo); +} + - ocp_data = tp->netdev->mtu + vlan_eth_hlen + eth_fcs_len; - ocp_write_word(tp, mcu_type_pla, pla_rms, ocp_data); - ocp_write_byte(tp, mcu_type_pla, pla_mtps, mtps_jumbo); + rtl8153_change_mtu(tp); - ocp_data = tp->netdev->mtu + vlan_eth_hlen + eth_fcs_len; - ocp_write_word(tp, mcu_type_pla, pla_rms, ocp_data); + ocp_write_word(tp, mcu_type_pla, pla_rms, mtu_to_size(tp->netdev->mtu)); - u32 rms = new_mtu + vlan_eth_hlen + eth_fcs_len; - - ocp_write_word(tp, mcu_type_pla, pla_rms, rms); + if (tp->rtl_ops.change_mtu) + tp->rtl_ops.change_mtu(tp); - if (netif_carrier_ok(dev)) - r8153_set_rx_early_size(tp); + if (netif_carrier_ok(dev)) { + netif_stop_queue(dev); + napi_disable(&tp->napi); + tasklet_disable(&tp->tx_tl); + tp->rtl_ops.disable(tp); + tp->rtl_ops.enable(tp); + rtl_start_rx(tp); + tasklet_enable(&tp->tx_tl); + napi_enable(&tp->napi); + rtl8152_set_rx_mode(dev); + netif_wake_queue(dev); + } + ops->change_mtu = rtl8153_change_mtu; + ops->change_mtu = rtl8153_change_mtu; - netdev->max_mtu = rtl8153_max_mtu; + netdev->max_mtu = size_to_mtu(9 * 1024);
|
Networking
|
67ce1a806f164e59a074fea8809725d3411eaa20
|
hayes wang
|
drivers
|
net
|
usb
|
r8152: support new chips
|
support rtl8153c, rtl8153d, rtl8156a, and rtl8156b. the rtl8156a and rtl8156b are the 2.5g ethernet.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
support new chips
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['r8152']
|
['c']
| 1
| 2,359
| 275
|
--- diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c +#define pla_rcr1 0xc012 +#define pla_rxfifo_full 0xc0a2 +#define pla_rx_fifo_full 0xc0a6 +#define pla_rx_fifo_empty 0xc0aa +#define pla_gphy_ctrl 0xd3ae +#define pla_pol_gpio_ctrl 0xdc6a +#define pla_eee_txtwsys 0xe04c +#define pla_eee_txtwsys_2p5g 0xe058 +#define pla_txfifo_full 0xe61a +#define pla_usb_cfg 0xe952 +#define usb_l1_ctrl 0xb45e +#define usb_ecm_option 0xcfee +#define usb_misc_2 0xcfff +#define usb_ecm_op 0xd26b +#define usb_gphy_ctrl 0xd284 +#define usb_speed_option 0xd32a +#define usb_uphy3_mdcmdio 0xd480 +#define usb_bmu_config 0xd4b4 +#define usb_rx_aggr_num 0xd4ee +#define usb_uphy_xtal 0xd826 +#define ocp_10gbt_ctrl 0xa5d4 +#define ocp_10gbt_stat 0xa5d6 +#define ocp_eee_adv2 0xa6d4 +#define sram_gphy_fw_ver 0x801e +#define slot_en bit(11) + +/* pla_rcr1 */ +#define outer_vlan bit(7) +#define inner_vlan bit(6) +/* pla_rxfifo_full */ +#define rxfifo_full_mask 0xfff + +#define flow_ctrl_en bit(0) +/* pla_usb_cfg */ +#define en_xg_lip bit(1) +#define en_g_lip bit(2) + +#define eee_spdwn_ratio_mask 0xff +#define idle_spdwn_en bit(6) +/* pla_gphy_ctrl */ +#define gphy_flash bit(1) + +/* pla_pol_gpio_ctrl */ +#define dack_det_en bit(15) +#define pol_gphy_patch bit(4) + +/* usb_bmu_config */ +#define act_odma bit(1) + +/* usb_rx_aggr_num */ +#define rx_aggr_num_mask 0x1ff + +/* usb_ecm_option */ +#define bypass_mac_reset bit(5) + +/* usb_misc_2 */ +#define ups_force_pwr_down bit(0) + +/* usb_ecm_op */ +#define en_all_speed bit(0) + +/* usb_gphy_ctrl */ +#define gphy_patch_done bit(2) +#define bypass_flash bit(5) +#define backup_restrore bit(6) + +/* usb_speed_option */ +#define rg_pwrdn_en bit(8) +#define all_speed_off bit(9) + +#define auto_speedup bit(3) +#define flow_ctrl_patch_2 bit(8) +#define cdc_ecm_en bit(3) +#define rx_detect8 bit(3) +/* usb_uphy_xtal */ +#define oobs_polling bit(8) + +#define mid_reverse bit(5) /* rtl8156a */ +#define ups_flags_speed_mask (0xf << 16) + force_1000m_full, + nway_2500m_full, +/* ocp_10gbt_ctrl */ +#define rtl_adv2_5g_f_r bit(5) /* advertise 2.5gbase-t fast-retrain */ + -#define clk_div_expo(x) (min(x, 5) << 8) +#define sysclk_div_expo(x) (min(x, 5) << 8) +#define clk_div_expo(x) (min(x, 5) << 4) + _2500bps = bit(10), + _1250bps = bit(9), + _500bps = bit(8), + _tx_flow = bit(6), + _rx_flow = bit(5), +#define is_speed_2500(_speed) (((_speed) & (_2500bps | link_status)) == (_2500bps | link_status)) +#define is_flow_control(_speed) (((_speed) & (_tx_flow | _rx_flow)) == (_tx_flow | _rx_flow)) + -#define rtl8152_napi_weight 64 + u32 r_tune:1; + u32 fc_pause_on, fc_pause_off; + u32 support_2500full:1; + + rtl_test_01, + rtl_ver_10, + rtl_ver_11, + rtl_ver_12, + rtl_ver_13, + rtl_ver_14, + rtl_ver_15, + +#define rtl_advertised_2500_full bit(6) - u32 ocp_data; + u32 ocp_data; - int i; + u32 ocp_data; + int i; - ocp_write_byte(tp, mcu_type_pla, pla_cr, cr_rst); + switch (tp->version) { + case rtl_test_01: + case rtl_ver_10: + case rtl_ver_11: + ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_cr); + ocp_data &= ~cr_te; + ocp_write_byte(tp, mcu_type_pla, pla_cr, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_bmu_reset); + ocp_data &= ~bmu_reset_ep_in; + ocp_write_word(tp, mcu_type_usb, usb_bmu_reset, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_usb_ctrl); + ocp_data |= cdc_ecm_en; + ocp_write_word(tp, mcu_type_usb, usb_usb_ctrl, ocp_data); + + ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_cr); + ocp_data &= ~cr_re; + ocp_write_byte(tp, mcu_type_pla, pla_cr, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_bmu_reset); + ocp_data |= bmu_reset_ep_in; + ocp_write_word(tp, mcu_type_usb, usb_bmu_reset, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_usb_ctrl); + ocp_data &= ~cdc_ecm_en; + ocp_write_word(tp, mcu_type_usb, usb_usb_ctrl, ocp_data); + break; - for (i = 0; i < 1000; i++) { - if (!(ocp_read_byte(tp, mcu_type_pla, pla_cr) & cr_rst)) - break; - usleep_range(100, 400); + default: + ocp_write_byte(tp, mcu_type_pla, pla_cr, cr_rst); + + for (i = 0; i < 1000; i++) { + if (!(ocp_read_byte(tp, mcu_type_pla, pla_cr) & cr_rst)) + break; + usleep_range(100, 400); + } + break; -static inline u8 rtl8152_get_speed(struct r8152 *tp) +static inline u16 rtl8152_get_speed(struct r8152 *tp) - return ocp_read_byte(tp, mcu_type_pla, pla_phystatus); + return ocp_read_word(tp, mcu_type_pla, pla_phystatus); + case rtl_ver_14: + case rtl_ver_14: + case rtl_ver_10: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_15: + ocp_write_word(tp, mcu_type_usb, usb_rx_early_timeout, + 640 / 8); + ocp_write_word(tp, mcu_type_usb, usb_rx_extra_aggr_tmr, + ocp_data); + r8153b_rx_agg_chg_indicate(tp); + break; + + case rtl_ver_14: + ocp_write_word(tp, mcu_type_usb, usb_rx_early_size, + ocp_data / 8); + break; + case rtl_test_01: + case rtl_ver_10: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_15: + r8153b_rx_agg_chg_indicate(tp); + u32 ocp_data; + - if (tp->version == rtl_ver_09) { - u32 ocp_data; - + switch (tp->version) { + case rtl_ver_09: + case rtl_ver_14: + break; + default: + break; - ocp_data = ocp_read_word(tp, mcu_type_pla, pla_cpcr); - if (enable) - ocp_data |= cpcr_rx_vlan; - else - ocp_data &= ~cpcr_rx_vlan; - ocp_write_word(tp, mcu_type_pla, pla_cpcr, ocp_data); + switch (tp->version) { + case rtl_ver_01: + case rtl_ver_02: + case rtl_ver_03: + case rtl_ver_04: + case rtl_ver_05: + case rtl_ver_06: + case rtl_ver_07: + case rtl_ver_08: + case rtl_ver_09: + case rtl_ver_14: + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_cpcr); + if (enable) + ocp_data |= cpcr_rx_vlan; + else + ocp_data &= ~cpcr_rx_vlan; + ocp_write_word(tp, mcu_type_pla, pla_cpcr, ocp_data); + break; + + case rtl_test_01: + case rtl_ver_10: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_15: + default: + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_rcr1); + if (enable) + ocp_data |= outer_vlan | inner_vlan; + else + ocp_data &= ~(outer_vlan | inner_vlan); + ocp_write_word(tp, mcu_type_pla, pla_rcr1, ocp_data); + break; + } +static void r8153_mac_clk_speed_down(struct r8152 *tp, bool enable) +{ + u32 ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl2); + + /* mac clock speed down */ + if (enable) + ocp_data |= mac_clk_spdwn_en; + else + ocp_data &= ~mac_clk_spdwn_en; + + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl2, ocp_data); +} + +static void r8156_mac_clk_spd(struct r8152 *tp, bool enable) +{ + u32 ocp_data; + + /* mac clock speed down */ + if (enable) { + /* aldps_spdwn_ratio, tp10_spdwn_ratio */ + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl, + 0x0403); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl2); + ocp_data &= ~eee_spdwn_ratio_mask; + ocp_data |= mac_clk_spdwn_en | 0x03; /* eee_spdwn_ratio */ + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl2, ocp_data); + } else { + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl2); + ocp_data &= ~mac_clk_spdwn_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl2, ocp_data); + } +} + + if (tp->ups_info.r_tune) + ups_flags |= ups_flags_r_tune; + +static void r8156_ups_flags(struct r8152 *tp) +{ + u32 ups_flags = 0; + + if (tp->ups_info.green) + ups_flags |= ups_flags_en_green; + + if (tp->ups_info.aldps) + ups_flags |= ups_flags_en_aldps; + + if (tp->ups_info.eee) + ups_flags |= ups_flags_en_eee; + + if (tp->ups_info.flow_control) + ups_flags |= ups_flags_en_flow_ctr; + + if (tp->ups_info.eee_ckdiv) + ups_flags |= ups_flags_en_eee_ckdiv; + + if (tp->ups_info._10m_ckdiv) + ups_flags |= ups_flags_en_10m_ckdiv; + + if (tp->ups_info.eee_plloff_100) + ups_flags |= ups_flags_eee_plloff_100; + + if (tp->ups_info.eee_plloff_giga) + ups_flags |= ups_flags_eee_plloff_giga; + + if (tp->ups_info._250m_ckdiv) + ups_flags |= ups_flags_250m_ckdiv; + + switch (tp->ups_info.speed_duplex) { + case force_10m_half: + ups_flags |= ups_flags_speed(0); + break; + case force_10m_full: + ups_flags |= ups_flags_speed(1); + break; + case force_100m_half: + ups_flags |= ups_flags_speed(2); + break; + case force_100m_full: + ups_flags |= ups_flags_speed(3); + break; + case nway_10m_half: + ups_flags |= ups_flags_speed(4); + break; + case nway_10m_full: + ups_flags |= ups_flags_speed(5); + break; + case nway_100m_half: + ups_flags |= ups_flags_speed(6); + break; + case nway_100m_full: + ups_flags |= ups_flags_speed(7); + break; + case nway_1000m_full: + ups_flags |= ups_flags_speed(8); + break; + case nway_2500m_full: + ups_flags |= ups_flags_speed(9); + break; + default: + break; + } + + switch (tp->ups_info.lite_mode) { + case 1: + ups_flags |= 0 << 5; + break; + case 2: + ups_flags |= 2 << 5; + break; + case 0: + default: + ups_flags |= 1 << 5; + break; + } + + ocp_write_dword(tp, mcu_type_usb, usb_ups_flags, ups_flags); +} + - ocp_data = ocp_read_byte(tp, mcu_type_usb, 0xcfff); - ocp_data |= bit(0); - ocp_write_byte(tp, mcu_type_usb, 0xcfff, ocp_data); + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_misc_2); + ocp_data |= ups_force_pwr_down; + ocp_write_byte(tp, mcu_type_usb, usb_misc_2, ocp_data); + } else { + ocp_data &= ~(ups_en | usp_prewake); + ocp_write_byte(tp, mcu_type_usb, usb_power_cut, ocp_data); + + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_misc_2); + ocp_data &= ~ups_force_pwr_down; + ocp_write_byte(tp, mcu_type_usb, usb_misc_2, ocp_data); + + if (ocp_read_word(tp, mcu_type_usb, usb_misc_0) & pcut_status) { + int i; + + for (i = 0; i < 500; i++) { + if (ocp_read_word(tp, mcu_type_pla, pla_boot_ctrl) & + autoload_done) + break; + msleep(20); + } + + tp->rtl_ops.hw_phy_cfg(tp); + + rtl8152_set_speed(tp, tp->autoneg, tp->speed, + tp->duplex, tp->advertising); + } + } +} + +static void r8153c_ups_en(struct r8152 *tp, bool enable) +{ + u32 ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_power_cut); + + if (enable) { + r8153b_ups_flags(tp); + + ocp_data |= ups_en | usp_prewake | phase2_en; + ocp_write_byte(tp, mcu_type_usb, usb_power_cut, ocp_data); + + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_misc_2); + ocp_data |= ups_force_pwr_down; + ocp_data &= ~bit(7); + ocp_write_byte(tp, mcu_type_usb, usb_misc_2, ocp_data); - ocp_data = ocp_read_byte(tp, mcu_type_usb, 0xcfff); - ocp_data &= ~bit(0); - ocp_write_byte(tp, mcu_type_usb, 0xcfff, ocp_data); + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_misc_2); + ocp_data &= ~ups_force_pwr_down; + ocp_write_byte(tp, mcu_type_usb, usb_misc_2, ocp_data); + + ocp_write_byte(tp, mcu_type_pla, pla_crwecr, crwecr_config); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_config34); + ocp_data |= bit(8); + ocp_write_word(tp, mcu_type_pla, pla_config34, ocp_data); + + ocp_write_byte(tp, mcu_type_pla, pla_crwecr, crwecr_noraml); + } +} + +static void r8156_ups_en(struct r8152 *tp, bool enable) +{ + u32 ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_power_cut); + + if (enable) { + r8156_ups_flags(tp); + + ocp_data |= ups_en | usp_prewake | phase2_en; + ocp_write_byte(tp, mcu_type_usb, usb_power_cut, ocp_data); + + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_misc_2); + ocp_data |= ups_force_pwr_down; + ocp_write_byte(tp, mcu_type_usb, usb_misc_2, ocp_data); + + switch (tp->version) { + case rtl_ver_13: + case rtl_ver_15: + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_uphy_xtal); + ocp_data &= ~oobs_polling; + ocp_write_byte(tp, mcu_type_usb, usb_uphy_xtal, ocp_data); + break; + default: + break; + } + } else { + ocp_data &= ~(ups_en | usp_prewake); + ocp_write_byte(tp, mcu_type_usb, usb_power_cut, ocp_data); + + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_misc_2); + ocp_data &= ~ups_force_pwr_down; + ocp_write_byte(tp, mcu_type_usb, usb_misc_2, ocp_data); + + if (ocp_read_word(tp, mcu_type_usb, usb_misc_0) & pcut_status) { + tp->rtl_ops.hw_phy_cfg(tp); + + rtl8152_set_speed(tp, tp->autoneg, tp->speed, + tp->duplex, tp->advertising); + } -static void r8153_teredo_off(struct r8152 *tp) +static void rtl8153c_runtime_enable(struct r8152 *tp, bool enable) - u32 ocp_data; + if (enable) { + r8153_queue_wake(tp, true); + r8153b_u1u2en(tp, false); + r8153_u2p3en(tp, false); + rtl_runtime_suspend_enable(tp, true); + r8153c_ups_en(tp, true); + } else { + r8153c_ups_en(tp, false); + r8153_queue_wake(tp, false); + rtl_runtime_suspend_enable(tp, false); + r8153b_u1u2en(tp, true); + } +} - switch (tp->version) { - case rtl_ver_01: - case rtl_ver_02: - case rtl_ver_03: - case rtl_ver_04: - case rtl_ver_05: - case rtl_ver_06: - case rtl_ver_07: - ocp_data = ocp_read_word(tp, mcu_type_pla, pla_teredo_cfg); - ocp_data &= ~(teredo_sel | teredo_rs_event_mask | - oob_teredo_en); - ocp_write_word(tp, mcu_type_pla, pla_teredo_cfg, ocp_data); - break; +static void rtl8156_runtime_enable(struct r8152 *tp, bool enable) +{ + if (enable) { + r8153_queue_wake(tp, true); + r8153b_u1u2en(tp, false); + r8153_u2p3en(tp, false); + rtl_runtime_suspend_enable(tp, true); + } else { + r8153_queue_wake(tp, false); + rtl_runtime_suspend_enable(tp, false); + r8153_u2p3en(tp, true); + if (tp->udev->speed >= usb_speed_super) + r8153b_u1u2en(tp, true); + } +} + +static void r8153_teredo_off(struct r8152 *tp) +{ + u32 ocp_data; + + switch (tp->version) { + case rtl_ver_01: + case rtl_ver_02: + case rtl_ver_03: + case rtl_ver_04: + case rtl_ver_05: + case rtl_ver_06: + case rtl_ver_07: + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_teredo_cfg); + ocp_data &= ~(teredo_sel | teredo_rs_event_mask | + oob_teredo_en); + ocp_write_word(tp, mcu_type_pla, pla_teredo_cfg, ocp_data); + break; + case rtl_test_01: + case rtl_ver_10: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_14: + case rtl_ver_15: + default: - - default: - break; + case rtl_ver_10: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_14: + case rtl_ver_15: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_14: + case rtl_ver_15: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_14: + case rtl_ver_15: +static void r8156_eee_en(struct r8152 *tp, bool enable) +{ + u16 config; + + r8153_eee_en(tp, enable); + + config = ocp_reg_read(tp, ocp_eee_adv2); + + if (enable) + config |= mdio_eee_2_5gt; + else + config &= ~mdio_eee_2_5gt; + + ocp_reg_write(tp, ocp_eee_adv2, config); +} + + case rtl_ver_14: + case rtl_ver_10: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_15: + if (enable) { + r8156_eee_en(tp, true); + ocp_reg_write(tp, ocp_eee_adv, tp->eee_adv); + } else { + r8156_eee_en(tp, false); + ocp_reg_write(tp, ocp_eee_adv, 0); + } + break; +static void r8156b_wait_loading_flash(struct r8152 *tp) +{ + if ((ocp_read_word(tp, mcu_type_pla, pla_gphy_ctrl) & gphy_flash) && + !(ocp_read_word(tp, mcu_type_usb, usb_gphy_ctrl) & bypass_flash)) { + int i; + + for (i = 0; i < 100; i++) { + if (ocp_read_word(tp, mcu_type_usb, usb_gphy_ctrl) & gphy_patch_done) + break; + usleep_range(1000, 2000); + } + } +} + - ocp_write_dword(tp, mcu_type_pla, pla_txfifo_ctrl, txfifo_thr_normal); + ocp_write_dword(tp, mcu_type_pla, pla_txfifo_ctrl, txfifo_thr_normal2); +static int r8153c_post_firmware_1(struct r8152 *tp) +{ + u32 ocp_data; + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_fw_ctrl); + ocp_data |= flow_ctrl_patch_2; + ocp_write_word(tp, mcu_type_usb, usb_fw_ctrl, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_fw_task); + ocp_data |= fc_patch_task; + ocp_write_word(tp, mcu_type_usb, usb_fw_task, ocp_data); + + return 0; +} + +static void r8153c_hw_phy_cfg(struct r8152 *tp) +{ + r8153b_hw_phy_cfg(tp); + + tp->ups_info.r_tune = true; +} + + case rtl_ver_14: +static int rtl8156_enable(struct r8152 *tp) +{ + u32 ocp_data; + u16 speed; + + if (test_bit(rtl8152_unplug, &tp->flags)) + return -enodev; + + set_tx_qlen(tp); + rtl_set_eee_plus(tp); + r8153_set_rx_early_timeout(tp); + r8153_set_rx_early_size(tp); + + speed = rtl8152_get_speed(tp); + rtl_set_ifg(tp, speed); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4); + if (speed & _2500bps) + ocp_data &= ~idle_spdwn_en; + else + ocp_data |= idle_spdwn_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4, ocp_data); + + if (speed & _1000bps) + ocp_write_word(tp, mcu_type_pla, pla_eee_txtwsys, 0x11); + else if (speed & _500bps) + ocp_write_word(tp, mcu_type_pla, pla_eee_txtwsys, 0x3d); + + if (tp->udev->speed == usb_speed_high) { + /* usb 0xb45e[3:0] l1_nyet_hird */ + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_l1_ctrl); + ocp_data &= ~0xf; + if (is_flow_control(speed)) + ocp_data |= 0xf; + else + ocp_data |= 0x1; + ocp_write_word(tp, mcu_type_usb, usb_l1_ctrl, ocp_data); + } + + return rtl_enable(tp); +} + +static int rtl8156b_enable(struct r8152 *tp) +{ + u32 ocp_data; + u16 speed; + + if (test_bit(rtl8152_unplug, &tp->flags)) + return -enodev; + + set_tx_qlen(tp); + rtl_set_eee_plus(tp); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_rx_aggr_num); + ocp_data &= ~rx_aggr_num_mask; + ocp_write_word(tp, mcu_type_usb, usb_rx_aggr_num, ocp_data); + + r8153_set_rx_early_timeout(tp); + r8153_set_rx_early_size(tp); + + speed = rtl8152_get_speed(tp); + rtl_set_ifg(tp, speed); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4); + if (speed & _2500bps) + ocp_data &= ~idle_spdwn_en; + else + ocp_data |= idle_spdwn_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4, ocp_data); + + if (tp->udev->speed == usb_speed_high) { + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_l1_ctrl); + ocp_data &= ~0xf; + if (is_flow_control(speed)) + ocp_data |= 0xf; + else + ocp_data |= 0x1; + ocp_write_word(tp, mcu_type_usb, usb_l1_ctrl, ocp_data); + } + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_fw_task); + ocp_data &= ~fc_patch_task; + ocp_write_word(tp, mcu_type_usb, usb_fw_task, ocp_data); + usleep_range(1000, 2000); + ocp_data |= fc_patch_task; + ocp_write_word(tp, mcu_type_usb, usb_fw_task, ocp_data); + + return rtl_enable(tp); +} + - u16 anar, tmp1; + u16 orig, new1; - if (tp->mii.supports_gmii) + if (tp->mii.supports_gmii) { + if (tp->support_2500full) + support |= rtl_advertised_2500_full; + } + - anar = r8152_mdio_read(tp, mii_advertise); - tmp1 = anar & ~(advertise_10half | advertise_10full | + orig = r8152_mdio_read(tp, mii_advertise); + new1 = orig & ~(advertise_10half | advertise_10full | - tmp1 |= advertise_10half; + new1 |= advertise_10half; - tmp1 |= advertise_10full; + new1 |= advertise_10full; - tmp1 |= advertise_100half; + new1 |= advertise_100half; - tmp1 |= advertise_100full; + new1 |= advertise_100full; - if (anar != tmp1) { - r8152_mdio_write(tp, mii_advertise, tmp1); - tp->mii.advertising = tmp1; + if (orig != new1) { + r8152_mdio_write(tp, mii_advertise, new1); + tp->mii.advertising = new1; - u16 gbcr; - - gbcr = r8152_mdio_read(tp, mii_ctrl1000); - tmp1 = gbcr & ~(advertise_1000full | + orig = r8152_mdio_read(tp, mii_ctrl1000); + new1 = orig & ~(advertise_1000full | - tmp1 |= advertise_1000full; + new1 |= advertise_1000full; - if (gbcr != tmp1) - r8152_mdio_write(tp, mii_ctrl1000, tmp1); + if (orig != new1) + r8152_mdio_write(tp, mii_ctrl1000, new1); + } + + if (tp->support_2500full) { + orig = ocp_reg_read(tp, ocp_10gbt_ctrl); + new1 = orig & ~mdio_an_10gbt_ctrl_adv2_5g; + + if (advertising & rtl_advertised_2500_full) { + new1 |= mdio_an_10gbt_ctrl_adv2_5g; + tp->ups_info.speed_duplex = nway_2500m_full; + } + + if (orig != new1) + ocp_reg_write(tp, ocp_10gbt_ctrl, new1); -static bool rtl8152_in_nway(struct r8152 *tp) +static void rtl8153c_change_mtu(struct r8152 *tp) - u16 nway_state; + ocp_write_word(tp, mcu_type_pla, pla_rms, mtu_to_size(tp->netdev->mtu)); + ocp_write_byte(tp, mcu_type_pla, pla_mtps, 10 * 1024 / 64); - ocp_write_word(tp, mcu_type_pla, pla_ocp_gphy_base, 0x2000); - tp->ocp_base = 0x2000; - ocp_write_byte(tp, mcu_type_pla, 0xb014, 0x4c); /* phy state */ - nway_state = ocp_read_word(tp, mcu_type_pla, 0xb01a); + ocp_write_word(tp, mcu_type_pla, pla_txfifo_ctrl, 512 / 64); - /* bit 15: txdis_state, bit 14: abd_state */ - if (nway_state & 0xc000) - return false; + /* adjust the tx fifo free credit full threshold, otherwise + * the fifo would be too small to send a jumbo frame packet. + */ + if (tp->netdev->mtu < 8000) + ocp_write_word(tp, mcu_type_pla, pla_txfifo_full, 2048 / 8); - return true; + ocp_write_word(tp, mcu_type_pla, pla_txfifo_full, 900 / 8); -static bool rtl8153_in_nway(struct r8152 *tp) +static void rtl8153c_up(struct r8152 *tp) - u16 phy_state = ocp_reg_read(tp, ocp_phy_state) & 0xff; - - if (phy_state == txdis_state || phy_state == abd_state) - return false; - else - return true; -} + u32 ocp_data; -static void set_carrier(struct r8152 *tp) -{ - struct net_device *netdev = tp->netdev; - struct napi_struct *napi = &tp->napi; - u8 speed; + if (test_bit(rtl8152_unplug, &tp->flags)) + return; - speed = rtl8152_get_speed(tp); + r8153b_u1u2en(tp, false); + r8153_u2p3en(tp, false); + r8153_aldps_en(tp, false); - if (speed & link_status) { - if (!netif_carrier_ok(netdev)) { - tp->rtl_ops.enable(tp); - netif_stop_queue(netdev); - napi_disable(napi); - netif_carrier_on(netdev); - rtl_start_rx(tp); - clear_bit(rtl8152_set_rx_mode, &tp->flags); - _rtl8152_set_rx_mode(netdev); - napi_enable(&tp->napi); - netif_wake_queue(netdev); - netif_info(tp, link, netdev, "carrier on "); - } else if (netif_queue_stopped(netdev) && - skb_queue_len(&tp->tx_queue) < tp->tx_qlen) { - netif_wake_queue(netdev); - } - } else { - if (netif_carrier_ok(netdev)) { - netif_carrier_off(netdev); - tasklet_disable(&tp->tx_tl); - napi_disable(napi); - tp->rtl_ops.disable(tp); - napi_enable(napi); - tasklet_enable(&tp->tx_tl); - netif_info(tp, link, netdev, "carrier off "); - } - } -} + rxdy_gated_en(tp, true); + r8153_teredo_off(tp); -static void rtl_work_func_t(struct work_struct *work) -{ - struct r8152 *tp = container_of(work, struct r8152, schedule.work); + ocp_data = ocp_read_dword(tp, mcu_type_pla, pla_rcr); + ocp_data &= ~rcr_acpt_all; + ocp_write_dword(tp, mcu_type_pla, pla_rcr, ocp_data); - /* if the device is unplugged or !netif_running(), the workqueue - * doesn't need to wake the device, and could return directly. - */ - if (test_bit(rtl8152_unplug, &tp->flags) || !netif_running(tp->netdev)) - return; + rtl8152_nic_reset(tp); + rtl_reset_bmu(tp); - if (usb_autopm_get_interface(tp->intf) < 0) - return; + ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_oob_ctrl); + ocp_data &= ~now_is_oob; + ocp_write_byte(tp, mcu_type_pla, pla_oob_ctrl, ocp_data); - if (!test_bit(work_enable, &tp->flags)) - goto out1; + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_sff_sts_7); + ocp_data &= ~mcu_borw_en; + ocp_write_word(tp, mcu_type_pla, pla_sff_sts_7, ocp_data); - if (!mutex_trylock(&tp->control)) { - schedule_delayed_work(&tp->schedule, 0); - goto out1; - } + wait_oob_link_list_ready(tp); - if (test_and_clear_bit(rtl8152_link_chg, &tp->flags)) - set_carrier(tp); + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_sff_sts_7); + ocp_data |= re_init_ll; + ocp_write_word(tp, mcu_type_pla, pla_sff_sts_7, ocp_data); - if (test_and_clear_bit(rtl8152_set_rx_mode, &tp->flags)) - _rtl8152_set_rx_mode(tp->netdev); + wait_oob_link_list_ready(tp); - /* don't schedule tasket before linking */ - if (test_and_clear_bit(schedule_tasklet, &tp->flags) && - netif_carrier_ok(tp->netdev)) - tasklet_schedule(&tp->tx_tl); + rtl_rx_vlan_en(tp, tp->netdev->features & netif_f_hw_vlan_ctag_rx); - mutex_unlock(&tp->control); + rtl8153c_change_mtu(tp); -out1: - usb_autopm_put_interface(tp->intf); -} + rtl8152_nic_reset(tp); -static void rtl_hw_phy_work_func_t(struct work_struct *work) -{ - struct r8152 *tp = container_of(work, struct r8152, hw_phy_work.work); + /* rx share fifo credit full threshold */ + ocp_write_byte(tp, mcu_type_pla, pla_rxfifo_ctrl0, 0x02); + ocp_write_byte(tp, mcu_type_pla, pla_rxfifo_full, 0x08); + ocp_write_word(tp, mcu_type_pla, pla_rxfifo_ctrl1, rxfifo_thr2_normal); + ocp_write_word(tp, mcu_type_pla, pla_rxfifo_ctrl2, rxfifo_thr3_normal); - if (test_bit(rtl8152_unplug, &tp->flags)) - return; + ocp_write_dword(tp, mcu_type_usb, usb_rx_buf_th, rx_thr_b); - if (usb_autopm_get_interface(tp->intf) < 0) - return; + ocp_write_byte(tp, mcu_type_pla, pla_crwecr, crwecr_config); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_config34); + ocp_data |= bit(8); + ocp_write_word(tp, mcu_type_pla, pla_config34, ocp_data); + + ocp_write_byte(tp, mcu_type_pla, pla_crwecr, crwecr_noraml); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3); + ocp_data &= ~pla_mcu_spdwn_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3, ocp_data); + + r8153_aldps_en(tp, true); + r8153b_u1u2en(tp, true); +} + +static inline u32 fc_pause_on_auto(struct r8152 *tp) +{ + return (align(mtu_to_size(tp->netdev->mtu), 1024) + 6 * 1024); +} + +static inline u32 fc_pause_off_auto(struct r8152 *tp) +{ + return (align(mtu_to_size(tp->netdev->mtu), 1024) + 14 * 1024); +} + +static void r8156_fc_parameter(struct r8152 *tp) +{ + u32 pause_on = tp->fc_pause_on ? tp->fc_pause_on : fc_pause_on_auto(tp); + u32 pause_off = tp->fc_pause_off ? tp->fc_pause_off : fc_pause_off_auto(tp); + + switch (tp->version) { + case rtl_ver_10: + case rtl_ver_11: + ocp_write_word(tp, mcu_type_pla, pla_rx_fifo_full, pause_on / 8); + ocp_write_word(tp, mcu_type_pla, pla_rx_fifo_empty, pause_off / 8); + break; + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_15: + ocp_write_word(tp, mcu_type_pla, pla_rx_fifo_full, pause_on / 16); + ocp_write_word(tp, mcu_type_pla, pla_rx_fifo_empty, pause_off / 16); + break; + default: + break; + } +} + +static void rtl8156_change_mtu(struct r8152 *tp) +{ + u32 rx_max_size = mtu_to_size(tp->netdev->mtu); + + ocp_write_word(tp, mcu_type_pla, pla_rms, rx_max_size); + ocp_write_byte(tp, mcu_type_pla, pla_mtps, mtps_jumbo); + r8156_fc_parameter(tp); + + /* tx share fifo free credit full threshold */ + ocp_write_word(tp, mcu_type_pla, pla_txfifo_ctrl, 512 / 64); + ocp_write_word(tp, mcu_type_pla, pla_txfifo_full, + align(rx_max_size + sizeof(struct tx_desc), 1024) / 16); +} + +static void rtl8156_up(struct r8152 *tp) +{ + u32 ocp_data; + + if (test_bit(rtl8152_unplug, &tp->flags)) + return; + + r8153b_u1u2en(tp, false); + r8153_u2p3en(tp, false); + r8153_aldps_en(tp, false); + + rxdy_gated_en(tp, true); + r8153_teredo_off(tp); + + ocp_data = ocp_read_dword(tp, mcu_type_pla, pla_rcr); + ocp_data &= ~rcr_acpt_all; + ocp_write_dword(tp, mcu_type_pla, pla_rcr, ocp_data); + + rtl8152_nic_reset(tp); + rtl_reset_bmu(tp); + + ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_oob_ctrl); + ocp_data &= ~now_is_oob; + ocp_write_byte(tp, mcu_type_pla, pla_oob_ctrl, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_sff_sts_7); + ocp_data &= ~mcu_borw_en; + ocp_write_word(tp, mcu_type_pla, pla_sff_sts_7, ocp_data); + + rtl_rx_vlan_en(tp, tp->netdev->features & netif_f_hw_vlan_ctag_rx); + + rtl8156_change_mtu(tp); + + switch (tp->version) { + case rtl_test_01: + case rtl_ver_10: + case rtl_ver_11: + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_bmu_config); + ocp_data |= act_odma; + ocp_write_word(tp, mcu_type_usb, usb_bmu_config, ocp_data); + break; + default: + break; + } + + /* share fifo settings */ + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_rxfifo_full); + ocp_data &= ~rxfifo_full_mask; + ocp_data |= 0x08; + ocp_write_word(tp, mcu_type_pla, pla_rxfifo_full, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3); + ocp_data &= ~pla_mcu_spdwn_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_speed_option); + ocp_data &= ~(rg_pwrdn_en | all_speed_off); + ocp_write_word(tp, mcu_type_usb, usb_speed_option, ocp_data); + + ocp_write_dword(tp, mcu_type_usb, usb_rx_buf_th, 0x00600400); + + if (tp->saved_wolopts != __rtl_get_wol(tp)) { + netif_warn(tp, ifup, tp->netdev, "wol setting is changed "); + __rtl_set_wol(tp, tp->saved_wolopts); + } + + r8153_aldps_en(tp, true); + r8153_u2p3en(tp, true); + + if (tp->udev->speed >= usb_speed_super) + r8153b_u1u2en(tp, true); +} + +static void rtl8156_down(struct r8152 *tp) +{ + u32 ocp_data; + + if (test_bit(rtl8152_unplug, &tp->flags)) { + rtl_drop_queued_tx(tp); + return; + } + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3); + ocp_data |= pla_mcu_spdwn_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3, ocp_data); + + r8153b_u1u2en(tp, false); + r8153_u2p3en(tp, false); + r8153b_power_cut_en(tp, false); + r8153_aldps_en(tp, false); + + ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_oob_ctrl); + ocp_data &= ~now_is_oob; + ocp_write_byte(tp, mcu_type_pla, pla_oob_ctrl, ocp_data); + + rtl_disable(tp); + rtl_reset_bmu(tp); + + /* clear teredo wake event. bit[15:8] is the teredo wakeup + * type. set it to zero. bits[7:0] are the w1c bits about + * the events. set them to all 1 to clear them. + */ + ocp_write_word(tp, mcu_type_pla, pla_teredo_wake_base, 0x00ff); + + ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_oob_ctrl); + ocp_data |= now_is_oob; + ocp_write_byte(tp, mcu_type_pla, pla_oob_ctrl, ocp_data); + + rtl_rx_vlan_en(tp, true); + rxdy_gated_en(tp, false); + + ocp_data = ocp_read_dword(tp, mcu_type_pla, pla_rcr); + ocp_data |= rcr_apm | rcr_am | rcr_ab; + ocp_write_dword(tp, mcu_type_pla, pla_rcr, ocp_data); + + r8153_aldps_en(tp, true); +} + +static bool rtl8152_in_nway(struct r8152 *tp) +{ + u16 nway_state; + + ocp_write_word(tp, mcu_type_pla, pla_ocp_gphy_base, 0x2000); + tp->ocp_base = 0x2000; + ocp_write_byte(tp, mcu_type_pla, 0xb014, 0x4c); /* phy state */ + nway_state = ocp_read_word(tp, mcu_type_pla, 0xb01a); + + /* bit 15: txdis_state, bit 14: abd_state */ + if (nway_state & 0xc000) + return false; + else + return true; +} + +static bool rtl8153_in_nway(struct r8152 *tp) +{ + u16 phy_state = ocp_reg_read(tp, ocp_phy_state) & 0xff; + + if (phy_state == txdis_state || phy_state == abd_state) + return false; + else + return true; +} + +static void set_carrier(struct r8152 *tp) +{ + struct net_device *netdev = tp->netdev; + struct napi_struct *napi = &tp->napi; + u16 speed; + + speed = rtl8152_get_speed(tp); + + if (speed & link_status) { + if (!netif_carrier_ok(netdev)) { + tp->rtl_ops.enable(tp); + netif_stop_queue(netdev); + napi_disable(napi); + netif_carrier_on(netdev); + rtl_start_rx(tp); + clear_bit(rtl8152_set_rx_mode, &tp->flags); + _rtl8152_set_rx_mode(netdev); + napi_enable(napi); + netif_wake_queue(netdev); + netif_info(tp, link, netdev, "carrier on "); + } else if (netif_queue_stopped(netdev) && + skb_queue_len(&tp->tx_queue) < tp->tx_qlen) { + netif_wake_queue(netdev); + } + } else { + if (netif_carrier_ok(netdev)) { + netif_carrier_off(netdev); + tasklet_disable(&tp->tx_tl); + napi_disable(napi); + tp->rtl_ops.disable(tp); + napi_enable(napi); + tasklet_enable(&tp->tx_tl); + netif_info(tp, link, netdev, "carrier off "); + } + } +} + +static void rtl_work_func_t(struct work_struct *work) +{ + struct r8152 *tp = container_of(work, struct r8152, schedule.work); + + /* if the device is unplugged or !netif_running(), the workqueue + * doesn't need to wake the device, and could return directly. + */ + if (test_bit(rtl8152_unplug, &tp->flags) || !netif_running(tp->netdev)) + return; + + if (usb_autopm_get_interface(tp->intf) < 0) + return; + + if (!test_bit(work_enable, &tp->flags)) + goto out1; + + if (!mutex_trylock(&tp->control)) { + schedule_delayed_work(&tp->schedule, 0); + goto out1; + } + + if (test_and_clear_bit(rtl8152_link_chg, &tp->flags)) + set_carrier(tp); + + if (test_and_clear_bit(rtl8152_set_rx_mode, &tp->flags)) + _rtl8152_set_rx_mode(tp->netdev); + + /* don't schedule tasket before linking */ + if (test_and_clear_bit(schedule_tasklet, &tp->flags) && + netif_carrier_ok(tp->netdev)) + tasklet_schedule(&tp->tx_tl); + + mutex_unlock(&tp->control); + +out1: + usb_autopm_put_interface(tp->intf); +} + +static void rtl_hw_phy_work_func_t(struct work_struct *work) +{ + struct r8152 *tp = container_of(work, struct r8152, hw_phy_work.work); + + if (test_bit(rtl8152_unplug, &tp->flags)) + return; + + if (usb_autopm_get_interface(tp->intf) < 0) + return; -static void r8153_init(struct r8152 *tp) +static void r8153_init(struct r8152 *tp) +{ + u32 ocp_data; + u16 data; + int i; + + if (test_bit(rtl8152_unplug, &tp->flags)) + return; + + r8153_u1u2en(tp, false); + + for (i = 0; i < 500; i++) { + if (ocp_read_word(tp, mcu_type_pla, pla_boot_ctrl) & + autoload_done) + break; + + msleep(20); + if (test_bit(rtl8152_unplug, &tp->flags)) + break; + } + + data = r8153_phy_status(tp, 0); + + if (tp->version == rtl_ver_03 || tp->version == rtl_ver_04 || + tp->version == rtl_ver_05) + ocp_reg_write(tp, ocp_adc_cfg, ckadsel_l | adc_en | en_emi_l); + + data = r8152_mdio_read(tp, mii_bmcr); + if (data & bmcr_pdown) { + data &= ~bmcr_pdown; + r8152_mdio_write(tp, mii_bmcr, data); + } + + data = r8153_phy_status(tp, phy_stat_lan_on); + + r8153_u2p3en(tp, false); + + if (tp->version == rtl_ver_04) { + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_ssphylink2); + ocp_data &= ~pwd_dn_scale_mask; + ocp_data |= pwd_dn_scale(96); + ocp_write_word(tp, mcu_type_usb, usb_ssphylink2, ocp_data); + + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_usb2phy); + ocp_data |= usb2phy_l1 | usb2phy_suspend; + ocp_write_byte(tp, mcu_type_usb, usb_usb2phy, ocp_data); + } else if (tp->version == rtl_ver_05) { + ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_dmy_reg0); + ocp_data &= ~ecm_aldps; + ocp_write_byte(tp, mcu_type_pla, pla_dmy_reg0, ocp_data); + + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_csr_dummy1); + if (ocp_read_word(tp, mcu_type_usb, usb_burst_size) == 0) + ocp_data &= ~dynamic_burst; + else + ocp_data |= dynamic_burst; + ocp_write_byte(tp, mcu_type_usb, usb_csr_dummy1, ocp_data); + } else if (tp->version == rtl_ver_06) { + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_csr_dummy1); + if (ocp_read_word(tp, mcu_type_usb, usb_burst_size) == 0) + ocp_data &= ~dynamic_burst; + else + ocp_data |= dynamic_burst; + ocp_write_byte(tp, mcu_type_usb, usb_csr_dummy1, ocp_data); + + r8153_queue_wake(tp, false); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_extra_status); + if (rtl8152_get_speed(tp) & link_status) + ocp_data |= cur_link_ok; + else + ocp_data &= ~cur_link_ok; + ocp_data |= poll_link_chg; + ocp_write_word(tp, mcu_type_pla, pla_extra_status, ocp_data); + } + + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_csr_dummy2); + ocp_data |= ep4_full_fc; + ocp_write_byte(tp, mcu_type_usb, usb_csr_dummy2, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_wdt11_ctrl); + ocp_data &= ~timer11_en; + ocp_write_word(tp, mcu_type_usb, usb_wdt11_ctrl, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_led_feature); + ocp_data &= ~led_mode_mask; + ocp_write_word(tp, mcu_type_pla, pla_led_feature, ocp_data); + + ocp_data = fifo_empty_1fb | rok_exit_lpm; + if (tp->version == rtl_ver_04 && tp->udev->speed < usb_speed_super) + ocp_data |= lpm_timer_500ms; + else + ocp_data |= lpm_timer_500us; + ocp_write_byte(tp, mcu_type_usb, usb_lpm_ctrl, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_afe_ctrl2); + ocp_data &= ~sen_val_mask; + ocp_data |= sen_val_normal | sel_rxidle; + ocp_write_word(tp, mcu_type_usb, usb_afe_ctrl2, ocp_data); + + ocp_write_word(tp, mcu_type_usb, usb_connect_timer, 0x0001); + + r8153_power_cut_en(tp, false); + rtl_runtime_suspend_enable(tp, false); + r8153_mac_clk_speed_down(tp, false); + r8153_u1u2en(tp, true); + usb_enable_lpm(tp->udev); + + ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_config6); + ocp_data |= lanwake_clr_en; + ocp_write_byte(tp, mcu_type_pla, pla_config6, ocp_data); + + ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_lwake_ctrl_reg); + ocp_data &= ~lanwake_pin; + ocp_write_byte(tp, mcu_type_pla, pla_lwake_ctrl_reg, ocp_data); + + /* rx aggregation */ + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_usb_ctrl); + ocp_data &= ~(rx_agg_disable | rx_zero_en); + if (test_bit(dell_tb_rx_agg_bug, &tp->flags)) + ocp_data |= rx_agg_disable; + + ocp_write_word(tp, mcu_type_usb, usb_usb_ctrl, ocp_data); + + rtl_tally_reset(tp); + + switch (tp->udev->speed) { + case usb_speed_super: + case usb_speed_super_plus: + tp->coalesce = coalesce_super; + break; + case usb_speed_high: + tp->coalesce = coalesce_high; + break; + default: + tp->coalesce = coalesce_slow; + break; + } +} + +static void r8153b_init(struct r8152 *tp) +{ + u32 ocp_data; + u16 data; + int i; + + if (test_bit(rtl8152_unplug, &tp->flags)) + return; + + r8153b_u1u2en(tp, false); + + for (i = 0; i < 500; i++) { + if (ocp_read_word(tp, mcu_type_pla, pla_boot_ctrl) & + autoload_done) + break; + + msleep(20); + if (test_bit(rtl8152_unplug, &tp->flags)) + break; + } + + data = r8153_phy_status(tp, 0); + + data = r8152_mdio_read(tp, mii_bmcr); + if (data & bmcr_pdown) { + data &= ~bmcr_pdown; + r8152_mdio_write(tp, mii_bmcr, data); + } + + data = r8153_phy_status(tp, phy_stat_lan_on); + + r8153_u2p3en(tp, false); + + /* msc timer = 0xfff * 8ms = 32760 ms */ + ocp_write_word(tp, mcu_type_usb, usb_msc_timer, 0x0fff); + + r8153b_power_cut_en(tp, false); + r8153b_ups_en(tp, false); + r8153_queue_wake(tp, false); + rtl_runtime_suspend_enable(tp, false); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_extra_status); + if (rtl8152_get_speed(tp) & link_status) + ocp_data |= cur_link_ok; + else + ocp_data &= ~cur_link_ok; + ocp_data |= poll_link_chg; + ocp_write_word(tp, mcu_type_pla, pla_extra_status, ocp_data); + + if (tp->udev->speed >= usb_speed_super) + r8153b_u1u2en(tp, true); + + usb_enable_lpm(tp->udev); + + /* mac clock speed down */ + r8153_mac_clk_speed_down(tp, true); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3); + ocp_data &= ~pla_mcu_spdwn_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3, ocp_data); + + if (tp->version == rtl_ver_09) { + /* disable test io for 32qfn */ + if (ocp_read_byte(tp, mcu_type_pla, 0xdc00) & bit(5)) { + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_phy_pwr); + ocp_data |= test_io_off; + ocp_write_word(tp, mcu_type_pla, pla_phy_pwr, ocp_data); + } + } + + set_bit(green_ethernet, &tp->flags); + + /* rx aggregation */ + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_usb_ctrl); + ocp_data &= ~(rx_agg_disable | rx_zero_en); + ocp_write_word(tp, mcu_type_usb, usb_usb_ctrl, ocp_data); + + rtl_tally_reset(tp); + + tp->coalesce = 15000; /* 15 us */ +} + +static void r8153c_init(struct r8152 *tp) +{ + u32 ocp_data; + u16 data; + int i; + + if (test_bit(rtl8152_unplug, &tp->flags)) + return; + + r8153b_u1u2en(tp, false); + + /* disable spi_en */ + ocp_write_byte(tp, mcu_type_pla, pla_crwecr, crwecr_config); + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_config5); + ocp_data &= ~bit(3); + ocp_write_word(tp, mcu_type_pla, pla_config5, ocp_data); + ocp_data = ocp_read_word(tp, mcu_type_usb, 0xcbf0); + ocp_data |= bit(1); + ocp_write_word(tp, mcu_type_usb, 0xcbf0, ocp_data); + + for (i = 0; i < 500; i++) { + if (ocp_read_word(tp, mcu_type_pla, pla_boot_ctrl) & + autoload_done) + break; + + msleep(20); + if (test_bit(rtl8152_unplug, &tp->flags)) + return; + } + + data = r8153_phy_status(tp, 0); + + data = r8152_mdio_read(tp, mii_bmcr); + if (data & bmcr_pdown) { + data &= ~bmcr_pdown; + r8152_mdio_write(tp, mii_bmcr, data); + } + + data = r8153_phy_status(tp, phy_stat_lan_on); + + r8153_u2p3en(tp, false); + + /* msc timer = 0xfff * 8ms = 32760 ms */ + ocp_write_word(tp, mcu_type_usb, usb_msc_timer, 0x0fff); + + r8153b_power_cut_en(tp, false); + r8153c_ups_en(tp, false); + r8153_queue_wake(tp, false); + rtl_runtime_suspend_enable(tp, false); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_extra_status); + if (rtl8152_get_speed(tp) & link_status) + ocp_data |= cur_link_ok; + else + ocp_data &= ~cur_link_ok; + + ocp_data |= poll_link_chg; + ocp_write_word(tp, mcu_type_pla, pla_extra_status, ocp_data); + + r8153b_u1u2en(tp, true); + + usb_enable_lpm(tp->udev); + + /* mac clock speed down */ + r8153_mac_clk_speed_down(tp, true); + + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_misc_2); + ocp_data &= ~bit(7); + ocp_write_byte(tp, mcu_type_usb, usb_misc_2, ocp_data); + + set_bit(green_ethernet, &tp->flags); + + /* rx aggregation */ + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_usb_ctrl); + ocp_data &= ~(rx_agg_disable | rx_zero_en); + ocp_write_word(tp, mcu_type_usb, usb_usb_ctrl, ocp_data); + + rtl_tally_reset(tp); + + tp->coalesce = 15000; /* 15 us */ +} + +static void r8156_hw_phy_cfg(struct r8152 *tp) +{ + u32 ocp_data; + u16 data; + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_misc_0); + if (ocp_data & pcut_status) { + ocp_data &= ~pcut_status; + ocp_write_word(tp, mcu_type_usb, usb_misc_0, ocp_data); + } + + data = r8153_phy_status(tp, 0); + switch (data) { + case phy_stat_ext_init: + rtl8152_apply_firmware(tp, true); + + data = ocp_reg_read(tp, 0xa468); + data &= ~(bit(3) | bit(1)); + ocp_reg_write(tp, 0xa468, data); + break; + case phy_stat_lan_on: + case phy_stat_pwrdn: + default: + rtl8152_apply_firmware(tp, false); + break; + } + + /* disable aldps before updating the phy parameters */ + r8153_aldps_en(tp, false); + + /* disable eee before updating the phy parameters */ + rtl_eee_enable(tp, false); + + data = r8153_phy_status(tp, phy_stat_lan_on); + warn_on_once(data != phy_stat_lan_on); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_phy_pwr); + ocp_data |= pfm_pwm_switch; + ocp_write_word(tp, mcu_type_pla, pla_phy_pwr, ocp_data); + + switch (tp->version) { + case rtl_ver_10: + data = ocp_reg_read(tp, 0xad40); + data &= ~0x3ff; + data |= bit(7) | bit(2); + ocp_reg_write(tp, 0xad40, data); + + data = ocp_reg_read(tp, 0xad4e); + data |= bit(4); + ocp_reg_write(tp, 0xad4e, data); + data = ocp_reg_read(tp, 0xad16); + data &= ~0x3ff; + data |= 0x6; + ocp_reg_write(tp, 0xad16, data); + data = ocp_reg_read(tp, 0xad32); + data &= ~0x3f; + data |= 6; + ocp_reg_write(tp, 0xad32, data); + data = ocp_reg_read(tp, 0xac08); + data &= ~(bit(12) | bit(8)); + ocp_reg_write(tp, 0xac08, data); + data = ocp_reg_read(tp, 0xac8a); + data |= bit(12) | bit(13) | bit(14); + data &= ~bit(15); + ocp_reg_write(tp, 0xac8a, data); + data = ocp_reg_read(tp, 0xad18); + data |= bit(10); + ocp_reg_write(tp, 0xad18, data); + data = ocp_reg_read(tp, 0xad1a); + data |= 0x3ff; + ocp_reg_write(tp, 0xad1a, data); + data = ocp_reg_read(tp, 0xad1c); + data |= 0x3ff; + ocp_reg_write(tp, 0xad1c, data); + + data = sram_read(tp, 0x80ea); + data &= ~0xff00; + data |= 0xc400; + sram_write(tp, 0x80ea, data); + data = sram_read(tp, 0x80eb); + data &= ~0x0700; + data |= 0x0300; + sram_write(tp, 0x80eb, data); + data = sram_read(tp, 0x80f8); + data &= ~0xff00; + data |= 0x1c00; + sram_write(tp, 0x80f8, data); + data = sram_read(tp, 0x80f1); + data &= ~0xff00; + data |= 0x3000; + sram_write(tp, 0x80f1, data); + + data = sram_read(tp, 0x80fe); + data &= ~0xff00; + data |= 0xa500; + sram_write(tp, 0x80fe, data); + data = sram_read(tp, 0x8102); + data &= ~0xff00; + data |= 0x5000; + sram_write(tp, 0x8102, data); + data = sram_read(tp, 0x8015); + data &= ~0xff00; + data |= 0x3300; + sram_write(tp, 0x8015, data); + data = sram_read(tp, 0x8100); + data &= ~0xff00; + data |= 0x7000; + sram_write(tp, 0x8100, data); + data = sram_read(tp, 0x8014); + data &= ~0xff00; + data |= 0xf000; + sram_write(tp, 0x8014, data); + data = sram_read(tp, 0x8016); + data &= ~0xff00; + data |= 0x6500; + sram_write(tp, 0x8016, data); + data = sram_read(tp, 0x80dc); + data &= ~0xff00; + data |= 0xed00; + sram_write(tp, 0x80dc, data); + data = sram_read(tp, 0x80df); + data |= bit(8); + sram_write(tp, 0x80df, data); + data = sram_read(tp, 0x80e1); + data &= ~bit(8); + sram_write(tp, 0x80e1, data); + + data = ocp_reg_read(tp, 0xbf06); + data &= ~0x003f; + data |= 0x0038; + ocp_reg_write(tp, 0xbf06, data); + + sram_write(tp, 0x819f, 0xddb6); + + ocp_reg_write(tp, 0xbc34, 0x5555); + data = ocp_reg_read(tp, 0xbf0a); + data &= ~0x0e00; + data |= 0x0a00; + ocp_reg_write(tp, 0xbf0a, data); + + data = ocp_reg_read(tp, 0xbd2c); + data &= ~bit(13); + ocp_reg_write(tp, 0xbd2c, data); + break; + case rtl_ver_11: + data = ocp_reg_read(tp, 0xad16); + data |= 0x3ff; + ocp_reg_write(tp, 0xad16, data); + data = ocp_reg_read(tp, 0xad32); + data &= ~0x3f; + data |= 6; + ocp_reg_write(tp, 0xad32, data); + data = ocp_reg_read(tp, 0xac08); + data &= ~(bit(12) | bit(8)); + ocp_reg_write(tp, 0xac08, data); + data = ocp_reg_read(tp, 0xacc0); + data &= ~0x3; + data |= bit(1); + ocp_reg_write(tp, 0xacc0, data); + data = ocp_reg_read(tp, 0xad40); + data &= ~0xe7; + data |= bit(6) | bit(2); + ocp_reg_write(tp, 0xad40, data); + data = ocp_reg_read(tp, 0xac14); + data &= ~bit(7); + ocp_reg_write(tp, 0xac14, data); + data = ocp_reg_read(tp, 0xac80); + data &= ~(bit(8) | bit(9)); + ocp_reg_write(tp, 0xac80, data); + data = ocp_reg_read(tp, 0xac5e); + data &= ~0x7; + data |= bit(1); + ocp_reg_write(tp, 0xac5e, data); + ocp_reg_write(tp, 0xad4c, 0x00a8); + ocp_reg_write(tp, 0xac5c, 0x01ff); + data = ocp_reg_read(tp, 0xac8a); + data &= ~0xf0; + data |= bit(4) | bit(5); + ocp_reg_write(tp, 0xac8a, data); + ocp_reg_write(tp, 0xb87c, 0x8157); + data = ocp_reg_read(tp, 0xb87e); + data &= ~0xff00; + data |= 0x0500; + ocp_reg_write(tp, 0xb87e, data); + ocp_reg_write(tp, 0xb87c, 0x8159); + data = ocp_reg_read(tp, 0xb87e); + data &= ~0xff00; + data |= 0x0700; + ocp_reg_write(tp, 0xb87e, data); + + /* aagc */ + ocp_reg_write(tp, 0xb87c, 0x80a2); + ocp_reg_write(tp, 0xb87e, 0x0153); + ocp_reg_write(tp, 0xb87c, 0x809c); + ocp_reg_write(tp, 0xb87e, 0x0153); + + /* eee parameter */ + ocp_write_word(tp, mcu_type_pla, pla_eee_txtwsys_2p5g, 0x0056); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_usb_cfg); + ocp_data |= en_xg_lip | en_g_lip; + ocp_write_word(tp, mcu_type_pla, pla_usb_cfg, ocp_data); + + sram_write(tp, 0x8257, 0x020f); /* xg pll */ + sram_write(tp, 0x80ea, 0x7843); /* giga master */ + + if (rtl_phy_patch_request(tp, true, true)) + return; + + /* advance eee */ + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4); + ocp_data |= eee_spdwn_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4, ocp_data); + + data = ocp_reg_read(tp, ocp_down_speed); + data &= ~(en_eee_100 | en_eee_1000); + data |= en_10m_clkdiv; + ocp_reg_write(tp, ocp_down_speed, data); + tp->ups_info._10m_ckdiv = true; + tp->ups_info.eee_plloff_100 = false; + tp->ups_info.eee_plloff_giga = false; + + data = ocp_reg_read(tp, ocp_power_cfg); + data &= ~eee_clkdiv_en; + ocp_reg_write(tp, ocp_power_cfg, data); + tp->ups_info.eee_ckdiv = false; + + ocp_reg_write(tp, ocp_sysclk_cfg, 0); + ocp_reg_write(tp, ocp_sysclk_cfg, sysclk_div_expo(5)); + tp->ups_info._250m_ckdiv = false; + + rtl_phy_patch_request(tp, false, true); + + /* enable adc ibias cal */ + data = ocp_reg_read(tp, 0xd068); + data |= bit(13); + ocp_reg_write(tp, 0xd068, data); + + /* enable thermal sensor */ + data = sram_read(tp, 0x81a2); + data &= ~bit(8); + sram_write(tp, 0x81a2, data); + data = ocp_reg_read(tp, 0xb54c); + data &= ~0xff00; + data |= 0xdb00; + ocp_reg_write(tp, 0xb54c, data); + + /* nway 2.5g lite */ + data = ocp_reg_read(tp, 0xa454); + data &= ~bit(0); + ocp_reg_write(tp, 0xa454, data); + + /* cs dsp solution */ + data = ocp_reg_read(tp, ocp_10gbt_ctrl); + data |= rtl_adv2_5g_f_r; + ocp_reg_write(tp, ocp_10gbt_ctrl, data); + data = ocp_reg_read(tp, 0xad4e); + data &= ~bit(4); + ocp_reg_write(tp, 0xad4e, data); + data = ocp_reg_read(tp, 0xa86a); + data &= ~bit(0); + ocp_reg_write(tp, 0xa86a, data); + + /* mdi swap */ + if ((ocp_read_word(tp, mcu_type_usb, usb_ups_cfg) & mid_reverse) && + (ocp_reg_read(tp, 0xd068) & bit(1))) { + u16 swap_a, swap_b; + + data = ocp_reg_read(tp, 0xd068); + data &= ~0x1f; + data |= 0x1; /* p0 */ + ocp_reg_write(tp, 0xd068, data); + swap_a = ocp_reg_read(tp, 0xd06a); + data &= ~0x18; + data |= 0x18; /* p3 */ + ocp_reg_write(tp, 0xd068, data); + swap_b = ocp_reg_read(tp, 0xd06a); + data &= ~0x18; /* p0 */ + ocp_reg_write(tp, 0xd068, data); + ocp_reg_write(tp, 0xd06a, + (swap_a & ~0x7ff) | (swap_b & 0x7ff)); + data |= 0x18; /* p3 */ + ocp_reg_write(tp, 0xd068, data); + ocp_reg_write(tp, 0xd06a, + (swap_b & ~0x7ff) | (swap_a & 0x7ff)); + data &= ~0x18; + data |= 0x08; /* p1 */ + ocp_reg_write(tp, 0xd068, data); + swap_a = ocp_reg_read(tp, 0xd06a); + data &= ~0x18; + data |= 0x10; /* p2 */ + ocp_reg_write(tp, 0xd068, data); + swap_b = ocp_reg_read(tp, 0xd06a); + data &= ~0x18; + data |= 0x08; /* p1 */ + ocp_reg_write(tp, 0xd068, data); + ocp_reg_write(tp, 0xd06a, + (swap_a & ~0x7ff) | (swap_b & 0x7ff)); + data &= ~0x18; + data |= 0x10; /* p2 */ + ocp_reg_write(tp, 0xd068, data); + ocp_reg_write(tp, 0xd06a, + (swap_b & ~0x7ff) | (swap_a & 0x7ff)); + swap_a = ocp_reg_read(tp, 0xbd5a); + swap_b = ocp_reg_read(tp, 0xbd5c); + ocp_reg_write(tp, 0xbd5a, (swap_a & ~0x1f1f) | + ((swap_b & 0x1f) << 8) | + ((swap_b >> 8) & 0x1f)); + ocp_reg_write(tp, 0xbd5c, (swap_b & ~0x1f1f) | + ((swap_a & 0x1f) << 8) | + ((swap_a >> 8) & 0x1f)); + swap_a = ocp_reg_read(tp, 0xbc18); + swap_b = ocp_reg_read(tp, 0xbc1a); + ocp_reg_write(tp, 0xbc18, (swap_a & ~0x1f1f) | + ((swap_b & 0x1f) << 8) | + ((swap_b >> 8) & 0x1f)); + ocp_reg_write(tp, 0xbc1a, (swap_b & ~0x1f1f) | + ((swap_a & 0x1f) << 8) | + ((swap_a >> 8) & 0x1f)); + } + break; + default: + break; + } + + rtl_green_en(tp, test_bit(green_ethernet, &tp->flags)); + + data = ocp_reg_read(tp, 0xa428); + data &= ~bit(9); + ocp_reg_write(tp, 0xa428, data); + data = ocp_reg_read(tp, 0xa5ea); + data &= ~bit(0); + ocp_reg_write(tp, 0xa5ea, data); + tp->ups_info.lite_mode = 0; + + if (tp->eee_en) + rtl_eee_enable(tp, true); + + r8153_aldps_en(tp, true); + r8152b_enable_fc(tp); + r8153_u2p3en(tp, true); + + set_bit(phy_reset, &tp->flags); +} + +static void r8156b_hw_phy_cfg(struct r8152 *tp) +{ + u32 ocp_data; + u16 data; + + switch (tp->version) { + case rtl_ver_12: + ocp_reg_write(tp, 0xbf86, 0x9000); + data = ocp_reg_read(tp, 0xc402); + data |= bit(10); + ocp_reg_write(tp, 0xc402, data); + data &= ~bit(10); + ocp_reg_write(tp, 0xc402, data); + ocp_reg_write(tp, 0xbd86, 0x1010); + ocp_reg_write(tp, 0xbd88, 0x1010); + data = ocp_reg_read(tp, 0xbd4e); + data &= ~(bit(10) | bit(11)); + data |= bit(11); + ocp_reg_write(tp, 0xbd4e, data); + data = ocp_reg_read(tp, 0xbf46); + data &= ~0xf00; + data |= 0x700; + ocp_reg_write(tp, 0xbf46, data); + break; + case rtl_ver_13: + case rtl_ver_15: + r8156b_wait_loading_flash(tp); + break; + default: + break; + } + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_misc_0); + if (ocp_data & pcut_status) { + ocp_data &= ~pcut_status; + ocp_write_word(tp, mcu_type_usb, usb_misc_0, ocp_data); + } + + data = r8153_phy_status(tp, 0); + switch (data) { + case phy_stat_ext_init: + rtl8152_apply_firmware(tp, true); + + data = ocp_reg_read(tp, 0xa466); + data &= ~bit(0); + ocp_reg_write(tp, 0xa466, data); + + data = ocp_reg_read(tp, 0xa468); + data &= ~(bit(3) | bit(1)); + ocp_reg_write(tp, 0xa468, data); + break; + case phy_stat_lan_on: + case phy_stat_pwrdn: + default: + rtl8152_apply_firmware(tp, false); + break; + } + + data = r8152_mdio_read(tp, mii_bmcr); + if (data & bmcr_pdown) { + data &= ~bmcr_pdown; + r8152_mdio_write(tp, mii_bmcr, data); + } + + /* disable aldps before updating the phy parameters */ + r8153_aldps_en(tp, false); + + /* disable eee before updating the phy parameters */ + rtl_eee_enable(tp, false); + + data = r8153_phy_status(tp, phy_stat_lan_on); + warn_on_once(data != phy_stat_lan_on); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_phy_pwr); + ocp_data |= pfm_pwm_switch; + ocp_write_word(tp, mcu_type_pla, pla_phy_pwr, ocp_data); + + switch (tp->version) { + case rtl_ver_12: + data = ocp_reg_read(tp, 0xbc08); + data |= bit(3) | bit(2); + ocp_reg_write(tp, 0xbc08, data); + + data = sram_read(tp, 0x8fff); + data &= ~0xff00; + data |= 0x0400; + sram_write(tp, 0x8fff, data); + + data = ocp_reg_read(tp, 0xacda); + data |= 0xff00; + ocp_reg_write(tp, 0xacda, data); + data = ocp_reg_read(tp, 0xacde); + data |= 0xf000; + ocp_reg_write(tp, 0xacde, data); + ocp_reg_write(tp, 0xac8c, 0x0ffc); + ocp_reg_write(tp, 0xac46, 0xb7b4); + ocp_reg_write(tp, 0xac50, 0x0fbc); + ocp_reg_write(tp, 0xac3c, 0x9240); + ocp_reg_write(tp, 0xac4e, 0x0db4); + ocp_reg_write(tp, 0xacc6, 0x0707); + ocp_reg_write(tp, 0xacc8, 0xa0d3); + ocp_reg_write(tp, 0xad08, 0x0007); + + ocp_reg_write(tp, 0xb87c, 0x8560); + ocp_reg_write(tp, 0xb87e, 0x19cc); + ocp_reg_write(tp, 0xb87c, 0x8562); + ocp_reg_write(tp, 0xb87e, 0x19cc); + ocp_reg_write(tp, 0xb87c, 0x8564); + ocp_reg_write(tp, 0xb87e, 0x19cc); + ocp_reg_write(tp, 0xb87c, 0x8566); + ocp_reg_write(tp, 0xb87e, 0x147d); + ocp_reg_write(tp, 0xb87c, 0x8568); + ocp_reg_write(tp, 0xb87e, 0x147d); + ocp_reg_write(tp, 0xb87c, 0x856a); + ocp_reg_write(tp, 0xb87e, 0x147d); + ocp_reg_write(tp, 0xb87c, 0x8ffe); + ocp_reg_write(tp, 0xb87e, 0x0907); + ocp_reg_write(tp, 0xb87c, 0x80d6); + ocp_reg_write(tp, 0xb87e, 0x2801); + ocp_reg_write(tp, 0xb87c, 0x80f2); + ocp_reg_write(tp, 0xb87e, 0x2801); + ocp_reg_write(tp, 0xb87c, 0x80f4); + ocp_reg_write(tp, 0xb87e, 0x6077); + ocp_reg_write(tp, 0xb506, 0x01e7); + + ocp_reg_write(tp, 0xb87c, 0x8013); + ocp_reg_write(tp, 0xb87e, 0x0700); + ocp_reg_write(tp, 0xb87c, 0x8fb9); + ocp_reg_write(tp, 0xb87e, 0x2801); + ocp_reg_write(tp, 0xb87c, 0x8fba); + ocp_reg_write(tp, 0xb87e, 0x0100); + ocp_reg_write(tp, 0xb87c, 0x8fbc); + ocp_reg_write(tp, 0xb87e, 0x1900); + ocp_reg_write(tp, 0xb87c, 0x8fbe); + ocp_reg_write(tp, 0xb87e, 0xe100); + ocp_reg_write(tp, 0xb87c, 0x8fc0); + ocp_reg_write(tp, 0xb87e, 0x0800); + ocp_reg_write(tp, 0xb87c, 0x8fc2); + ocp_reg_write(tp, 0xb87e, 0xe500); + ocp_reg_write(tp, 0xb87c, 0x8fc4); + ocp_reg_write(tp, 0xb87e, 0x0f00); + ocp_reg_write(tp, 0xb87c, 0x8fc6); + ocp_reg_write(tp, 0xb87e, 0xf100); + ocp_reg_write(tp, 0xb87c, 0x8fc8); + ocp_reg_write(tp, 0xb87e, 0x0400); + ocp_reg_write(tp, 0xb87c, 0x8fca); + ocp_reg_write(tp, 0xb87e, 0xf300); + ocp_reg_write(tp, 0xb87c, 0x8fcc); + ocp_reg_write(tp, 0xb87e, 0xfd00); + ocp_reg_write(tp, 0xb87c, 0x8fce); + ocp_reg_write(tp, 0xb87e, 0xff00); + ocp_reg_write(tp, 0xb87c, 0x8fd0); + ocp_reg_write(tp, 0xb87e, 0xfb00); + ocp_reg_write(tp, 0xb87c, 0x8fd2); + ocp_reg_write(tp, 0xb87e, 0x0100); + ocp_reg_write(tp, 0xb87c, 0x8fd4); + ocp_reg_write(tp, 0xb87e, 0xf400); + ocp_reg_write(tp, 0xb87c, 0x8fd6); + ocp_reg_write(tp, 0xb87e, 0xff00); + ocp_reg_write(tp, 0xb87c, 0x8fd8); + ocp_reg_write(tp, 0xb87e, 0xf600); + + ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_usb_cfg); + ocp_data |= en_xg_lip | en_g_lip; + ocp_write_byte(tp, mcu_type_pla, pla_usb_cfg, ocp_data); + ocp_reg_write(tp, 0xb87c, 0x813d); + ocp_reg_write(tp, 0xb87e, 0x390e); + ocp_reg_write(tp, 0xb87c, 0x814f); + ocp_reg_write(tp, 0xb87e, 0x790e); + ocp_reg_write(tp, 0xb87c, 0x80b0); + ocp_reg_write(tp, 0xb87e, 0x0f31); + data = ocp_reg_read(tp, 0xbf4c); + data |= bit(1); + ocp_reg_write(tp, 0xbf4c, data); + data = ocp_reg_read(tp, 0xbcca); + data |= bit(9) | bit(8); + ocp_reg_write(tp, 0xbcca, data); + ocp_reg_write(tp, 0xb87c, 0x8141); + ocp_reg_write(tp, 0xb87e, 0x320e); + ocp_reg_write(tp, 0xb87c, 0x8153); + ocp_reg_write(tp, 0xb87e, 0x720e); + ocp_reg_write(tp, 0xb87c, 0x8529); + ocp_reg_write(tp, 0xb87e, 0x050e); + data = ocp_reg_read(tp, ocp_eee_cfg); + data &= ~ctap_short_en; + ocp_reg_write(tp, ocp_eee_cfg, data); + + sram_write(tp, 0x816c, 0xc4a0); + sram_write(tp, 0x8170, 0xc4a0); + sram_write(tp, 0x8174, 0x04a0); + sram_write(tp, 0x8178, 0x04a0); + sram_write(tp, 0x817c, 0x0719); + sram_write(tp, 0x8ff4, 0x0400); + sram_write(tp, 0x8ff1, 0x0404); + + ocp_reg_write(tp, 0xbf4a, 0x001b); + ocp_reg_write(tp, 0xb87c, 0x8033); + ocp_reg_write(tp, 0xb87e, 0x7c13); + ocp_reg_write(tp, 0xb87c, 0x8037); + ocp_reg_write(tp, 0xb87e, 0x7c13); + ocp_reg_write(tp, 0xb87c, 0x803b); + ocp_reg_write(tp, 0xb87e, 0xfc32); + ocp_reg_write(tp, 0xb87c, 0x803f); + ocp_reg_write(tp, 0xb87e, 0x7c13); + ocp_reg_write(tp, 0xb87c, 0x8043); + ocp_reg_write(tp, 0xb87e, 0x7c13); + ocp_reg_write(tp, 0xb87c, 0x8047); + ocp_reg_write(tp, 0xb87e, 0x7c13); + + ocp_reg_write(tp, 0xb87c, 0x8145); + ocp_reg_write(tp, 0xb87e, 0x370e); + ocp_reg_write(tp, 0xb87c, 0x8157); + ocp_reg_write(tp, 0xb87e, 0x770e); + ocp_reg_write(tp, 0xb87c, 0x8169); + ocp_reg_write(tp, 0xb87e, 0x0d0a); + ocp_reg_write(tp, 0xb87c, 0x817b); + ocp_reg_write(tp, 0xb87e, 0x1d0a); + + data = sram_read(tp, 0x8217); + data &= ~0xff00; + data |= 0x5000; + sram_write(tp, 0x8217, data); + data = sram_read(tp, 0x821a); + data &= ~0xff00; + data |= 0x5000; + sram_write(tp, 0x821a, data); + sram_write(tp, 0x80da, 0x0403); + data = sram_read(tp, 0x80dc); + data &= ~0xff00; + data |= 0x1000; + sram_write(tp, 0x80dc, data); + sram_write(tp, 0x80b3, 0x0384); + sram_write(tp, 0x80b7, 0x2007); + data = sram_read(tp, 0x80ba); + data &= ~0xff00; + data |= 0x6c00; + sram_write(tp, 0x80ba, data); + sram_write(tp, 0x80b5, 0xf009); + data = sram_read(tp, 0x80bd); + data &= ~0xff00; + data |= 0x9f00; + sram_write(tp, 0x80bd, data); + sram_write(tp, 0x80c7, 0xf083); + sram_write(tp, 0x80dd, 0x03f0); + data = sram_read(tp, 0x80df); + data &= ~0xff00; + data |= 0x1000; + sram_write(tp, 0x80df, data); + sram_write(tp, 0x80cb, 0x2007); + data = sram_read(tp, 0x80ce); + data &= ~0xff00; + data |= 0x6c00; + sram_write(tp, 0x80ce, data); + sram_write(tp, 0x80c9, 0x8009); + data = sram_read(tp, 0x80d1); + data &= ~0xff00; + data |= 0x8000; + sram_write(tp, 0x80d1, data); + sram_write(tp, 0x80a3, 0x200a); + sram_write(tp, 0x80a5, 0xf0ad); + sram_write(tp, 0x809f, 0x6073); + sram_write(tp, 0x80a1, 0x000b); + data = sram_read(tp, 0x80a9); + data &= ~0xff00; + data |= 0xc000; + sram_write(tp, 0x80a9, data); + + if (rtl_phy_patch_request(tp, true, true)) + return; + + data = ocp_reg_read(tp, 0xb896); + data &= ~bit(0); + ocp_reg_write(tp, 0xb896, data); + data = ocp_reg_read(tp, 0xb892); + data &= ~0xff00; + ocp_reg_write(tp, 0xb892, data); + ocp_reg_write(tp, 0xb88e, 0xc23e); + ocp_reg_write(tp, 0xb890, 0x0000); + ocp_reg_write(tp, 0xb88e, 0xc240); + ocp_reg_write(tp, 0xb890, 0x0103); + ocp_reg_write(tp, 0xb88e, 0xc242); + ocp_reg_write(tp, 0xb890, 0x0507); + ocp_reg_write(tp, 0xb88e, 0xc244); + ocp_reg_write(tp, 0xb890, 0x090b); + ocp_reg_write(tp, 0xb88e, 0xc246); + ocp_reg_write(tp, 0xb890, 0x0c0e); + ocp_reg_write(tp, 0xb88e, 0xc248); + ocp_reg_write(tp, 0xb890, 0x1012); + ocp_reg_write(tp, 0xb88e, 0xc24a); + ocp_reg_write(tp, 0xb890, 0x1416); + data = ocp_reg_read(tp, 0xb896); + data |= bit(0); + ocp_reg_write(tp, 0xb896, data); + + rtl_phy_patch_request(tp, false, true); + + data = ocp_reg_read(tp, 0xa86a); + data |= bit(0); + ocp_reg_write(tp, 0xa86a, data); + data = ocp_reg_read(tp, 0xa6f0); + data |= bit(0); + ocp_reg_write(tp, 0xa6f0, data); + + ocp_reg_write(tp, 0xbfa0, 0xd70d); + ocp_reg_write(tp, 0xbfa2, 0x4100); + ocp_reg_write(tp, 0xbfa4, 0xe868); + ocp_reg_write(tp, 0xbfa6, 0xdc59); + ocp_reg_write(tp, 0xb54c, 0x3c18); + data = ocp_reg_read(tp, 0xbfa4); + data &= ~bit(5); + ocp_reg_write(tp, 0xbfa4, data); + data = sram_read(tp, 0x817d); + data |= bit(12); + sram_write(tp, 0x817d, data); + break; + case rtl_ver_13: + /* 2.5g inrx */ + data = ocp_reg_read(tp, 0xac46); + data &= ~0x00f0; + data |= 0x0090; + ocp_reg_write(tp, 0xac46, data); + data = ocp_reg_read(tp, 0xad30); + data &= ~0x0003; + data |= 0x0001; + ocp_reg_write(tp, 0xad30, data); + fallthrough; + case rtl_ver_15: + /* eee parameter */ + ocp_reg_write(tp, 0xb87c, 0x80f5); + ocp_reg_write(tp, 0xb87e, 0x760e); + ocp_reg_write(tp, 0xb87c, 0x8107); + ocp_reg_write(tp, 0xb87e, 0x360e); + ocp_reg_write(tp, 0xb87c, 0x8551); + data = ocp_reg_read(tp, 0xb87e); + data &= ~0xff00; + data |= 0x0800; + ocp_reg_write(tp, 0xb87e, data); + + /* adc_pga parameter */ + data = ocp_reg_read(tp, 0xbf00); + data &= ~0xe000; + data |= 0xa000; + ocp_reg_write(tp, 0xbf00, data); + data = ocp_reg_read(tp, 0xbf46); + data &= ~0x0f00; + data |= 0x0300; + ocp_reg_write(tp, 0xbf46, data); + + /* green table-pga, 1g full viterbi */ + sram_write(tp, 0x8044, 0x2417); + sram_write(tp, 0x804a, 0x2417); + sram_write(tp, 0x8050, 0x2417); + sram_write(tp, 0x8056, 0x2417); + sram_write(tp, 0x805c, 0x2417); + sram_write(tp, 0x8062, 0x2417); + sram_write(tp, 0x8068, 0x2417); + sram_write(tp, 0x806e, 0x2417); + sram_write(tp, 0x8074, 0x2417); + sram_write(tp, 0x807a, 0x2417); + + /* xg pll */ + data = ocp_reg_read(tp, 0xbf84); + data &= ~0xe000; + data |= 0xa000; + ocp_reg_write(tp, 0xbf84, data); + break; + default: + break; + } + + if (rtl_phy_patch_request(tp, true, true)) + return; + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4); + ocp_data |= eee_spdwn_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4, ocp_data); + + data = ocp_reg_read(tp, ocp_down_speed); + data &= ~(en_eee_100 | en_eee_1000); + data |= en_10m_clkdiv; + ocp_reg_write(tp, ocp_down_speed, data); + tp->ups_info._10m_ckdiv = true; + tp->ups_info.eee_plloff_100 = false; + tp->ups_info.eee_plloff_giga = false; + + data = ocp_reg_read(tp, ocp_power_cfg); + data &= ~eee_clkdiv_en; + ocp_reg_write(tp, ocp_power_cfg, data); + tp->ups_info.eee_ckdiv = false; + + rtl_phy_patch_request(tp, false, true); + + rtl_green_en(tp, test_bit(green_ethernet, &tp->flags)); + + data = ocp_reg_read(tp, 0xa428); + data &= ~bit(9); + ocp_reg_write(tp, 0xa428, data); + data = ocp_reg_read(tp, 0xa5ea); + data &= ~bit(0); + ocp_reg_write(tp, 0xa5ea, data); + tp->ups_info.lite_mode = 0; + + if (tp->eee_en) + rtl_eee_enable(tp, true); + + r8153_aldps_en(tp, true); + r8152b_enable_fc(tp); + r8153_u2p3en(tp, true); + + set_bit(phy_reset, &tp->flags); +} + +static void r8156_init(struct r8152 *tp) - r8153_u1u2en(tp, false); + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_ecm_op); + ocp_data &= ~en_all_speed; + ocp_write_byte(tp, mcu_type_usb, usb_ecm_op, ocp_data); + + ocp_write_word(tp, mcu_type_usb, usb_speed_option, 0); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_ecm_option); + ocp_data |= bypass_mac_reset; + ocp_write_word(tp, mcu_type_usb, usb_ecm_option, ocp_data); + + r8153b_u1u2en(tp, false); - break; + return; - - if (tp->version == rtl_ver_03 || tp->version == rtl_ver_04 || - tp->version == rtl_ver_05) - ocp_reg_write(tp, ocp_adc_cfg, ckadsel_l | adc_en | en_emi_l); + if (data == phy_stat_ext_init) { + data = ocp_reg_read(tp, 0xa468); + data &= ~(bit(3) | bit(1)); + ocp_reg_write(tp, 0xa468, data); + } + warn_on_once(data != phy_stat_lan_on); - if (tp->version == rtl_ver_04) { - ocp_data = ocp_read_word(tp, mcu_type_usb, usb_ssphylink2); - ocp_data &= ~pwd_dn_scale_mask; - ocp_data |= pwd_dn_scale(96); - ocp_write_word(tp, mcu_type_usb, usb_ssphylink2, ocp_data); - - ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_usb2phy); - ocp_data |= usb2phy_l1 | usb2phy_suspend; - ocp_write_byte(tp, mcu_type_usb, usb_usb2phy, ocp_data); - } else if (tp->version == rtl_ver_05) { - ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_dmy_reg0); - ocp_data &= ~ecm_aldps; - ocp_write_byte(tp, mcu_type_pla, pla_dmy_reg0, ocp_data); + /* msc timer = 0xfff * 8ms = 32760 ms */ + ocp_write_word(tp, mcu_type_usb, usb_msc_timer, 0x0fff); - ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_csr_dummy1); - if (ocp_read_word(tp, mcu_type_usb, usb_burst_size) == 0) - ocp_data &= ~dynamic_burst; - else - ocp_data |= dynamic_burst; - ocp_write_byte(tp, mcu_type_usb, usb_csr_dummy1, ocp_data); - } else if (tp->version == rtl_ver_06) { - ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_csr_dummy1); - if (ocp_read_word(tp, mcu_type_usb, usb_burst_size) == 0) - ocp_data &= ~dynamic_burst; - else - ocp_data |= dynamic_burst; - ocp_write_byte(tp, mcu_type_usb, usb_csr_dummy1, ocp_data); + /* u1/u2/l1 idle timer. 500 us */ + ocp_write_word(tp, mcu_type_usb, usb_u1u2_timer, 500); - r8153_queue_wake(tp, false); + r8153b_power_cut_en(tp, false); + r8156_ups_en(tp, false); + r8153_queue_wake(tp, false); + rtl_runtime_suspend_enable(tp, false); - ocp_data = ocp_read_word(tp, mcu_type_pla, pla_extra_status); - if (rtl8152_get_speed(tp) & link_status) - ocp_data |= cur_link_ok; - else - ocp_data &= ~cur_link_ok; - ocp_data |= poll_link_chg; - ocp_write_word(tp, mcu_type_pla, pla_extra_status, ocp_data); - } + if (tp->udev->speed >= usb_speed_super) + r8153b_u1u2en(tp, true); - ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_csr_dummy2); - ocp_data |= ep4_full_fc; - ocp_write_byte(tp, mcu_type_usb, usb_csr_dummy2, ocp_data); + usb_enable_lpm(tp->udev); - ocp_data = ocp_read_word(tp, mcu_type_usb, usb_wdt11_ctrl); - ocp_data &= ~timer11_en; - ocp_write_word(tp, mcu_type_usb, usb_wdt11_ctrl, ocp_data); + r8156_mac_clk_spd(tp, true); - ocp_data = ocp_read_word(tp, mcu_type_pla, pla_led_feature); - ocp_data &= ~led_mode_mask; - ocp_write_word(tp, mcu_type_pla, pla_led_feature, ocp_data); + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3); + ocp_data &= ~pla_mcu_spdwn_en; + ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3, ocp_data); - ocp_data = fifo_empty_1fb | rok_exit_lpm; - if (tp->version == rtl_ver_04 && tp->udev->speed < usb_speed_super) - ocp_data |= lpm_timer_500ms; + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_extra_status); + if (rtl8152_get_speed(tp) & link_status) + ocp_data |= cur_link_ok; - ocp_data |= lpm_timer_500us; - ocp_write_byte(tp, mcu_type_usb, usb_lpm_ctrl, ocp_data); - - ocp_data = ocp_read_word(tp, mcu_type_usb, usb_afe_ctrl2); - ocp_data &= ~sen_val_mask; - ocp_data |= sen_val_normal | sel_rxidle; - ocp_write_word(tp, mcu_type_usb, usb_afe_ctrl2, ocp_data); - - ocp_write_word(tp, mcu_type_usb, usb_connect_timer, 0x0001); - - /* mac clock speed down */ - ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl, 0); - ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl2, 0); - ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl3, 0); - ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl4, 0); - - r8153_power_cut_en(tp, false); - rtl_runtime_suspend_enable(tp, false); - r8153_u1u2en(tp, true); - usb_enable_lpm(tp->udev); - - ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_config6); - ocp_data |= lanwake_clr_en; - ocp_write_byte(tp, mcu_type_pla, pla_config6, ocp_data); + ocp_data &= ~cur_link_ok; + ocp_data |= poll_link_chg; + ocp_write_word(tp, mcu_type_pla, pla_extra_status, ocp_data); - ocp_data = ocp_read_byte(tp, mcu_type_pla, pla_lwake_ctrl_reg); - ocp_data &= ~lanwake_pin; - ocp_write_byte(tp, mcu_type_pla, pla_lwake_ctrl_reg, ocp_data); + set_bit(green_ethernet, &tp->flags); - if (test_bit(dell_tb_rx_agg_bug, &tp->flags)) - ocp_data |= rx_agg_disable; - + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_bmu_config); + ocp_data |= act_odma; + ocp_write_byte(tp, mcu_type_usb, usb_bmu_config, ocp_data); + - switch (tp->udev->speed) { - case usb_speed_super: - case usb_speed_super_plus: - tp->coalesce = coalesce_super; - break; - case usb_speed_high: - tp->coalesce = coalesce_high; - break; - default: - tp->coalesce = coalesce_slow; - break; - } + tp->coalesce = 15000; /* 15 us */ -static void r8153b_init(struct r8152 *tp) +static void r8156b_init(struct r8152 *tp) + ocp_data = ocp_read_byte(tp, mcu_type_usb, usb_ecm_op); + ocp_data &= ~en_all_speed; + ocp_write_byte(tp, mcu_type_usb, usb_ecm_op, ocp_data); + + ocp_write_word(tp, mcu_type_usb, usb_speed_option, 0); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_ecm_option); + ocp_data |= bypass_mac_reset; + ocp_write_word(tp, mcu_type_usb, usb_ecm_option, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_u2p3_ctrl); + ocp_data |= rx_detect8; + ocp_write_word(tp, mcu_type_usb, usb_u2p3_ctrl, ocp_data); + + switch (tp->version) { + case rtl_ver_13: + case rtl_ver_15: + r8156b_wait_loading_flash(tp); + break; + default: + break; + } + - break; + return; + if (data == phy_stat_ext_init) { + data = ocp_reg_read(tp, 0xa468); + data &= ~(bit(3) | bit(1)); + ocp_reg_write(tp, 0xa468, data); + + data = ocp_reg_read(tp, 0xa466); + data &= ~bit(0); + ocp_reg_write(tp, 0xa466, data); + } + /* u1/u2/l1 idle timer. 500 us */ + ocp_write_word(tp, mcu_type_usb, usb_u1u2_timer, 500); + - r8153b_ups_en(tp, false); + r8156_ups_en(tp, false); - ocp_data = ocp_read_word(tp, mcu_type_pla, pla_extra_status); - if (rtl8152_get_speed(tp) & link_status) - ocp_data |= cur_link_ok; - else - ocp_data &= ~cur_link_ok; - ocp_data |= poll_link_chg; - ocp_write_word(tp, mcu_type_pla, pla_extra_status, ocp_data); - - /* mac clock speed down */ - ocp_data = ocp_read_word(tp, mcu_type_pla, pla_mac_pwr_ctrl2); - ocp_data |= mac_clk_spdwn_en; - ocp_write_word(tp, mcu_type_pla, pla_mac_pwr_ctrl2, ocp_data); + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_rcr); + ocp_data &= ~slot_en; + ocp_write_word(tp, mcu_type_pla, pla_rcr, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_cpcr); + ocp_data |= flow_ctrl_en; + ocp_write_word(tp, mcu_type_pla, pla_cpcr, ocp_data); + + /* enable fc timer and set timer to 600 ms. */ + ocp_write_word(tp, mcu_type_usb, usb_fc_timer, + ctrl_timer_en | (600 / 8)); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_fw_ctrl); + if (!(ocp_read_word(tp, mcu_type_pla, pla_pol_gpio_ctrl) & dack_det_en)) + ocp_data |= flow_ctrl_patch_2; + ocp_data &= ~auto_speedup; + ocp_write_word(tp, mcu_type_usb, usb_fw_ctrl, ocp_data); + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_fw_task); + ocp_data |= fc_patch_task; + ocp_write_word(tp, mcu_type_usb, usb_fw_task, ocp_data); + + r8156_mac_clk_spd(tp, true); - if (tp->version == rtl_ver_09) { - /* disable test io for 32qfn */ - if (ocp_read_byte(tp, mcu_type_pla, 0xdc00) & bit(5)) { - ocp_data = ocp_read_word(tp, mcu_type_pla, pla_phy_pwr); - ocp_data |= test_io_off; - ocp_write_word(tp, mcu_type_pla, pla_phy_pwr, ocp_data); - } - } + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_extra_status); + if (rtl8152_get_speed(tp) & link_status) + ocp_data |= cur_link_ok; + else + ocp_data &= ~cur_link_ok; + ocp_data |= poll_link_chg; + ocp_write_word(tp, mcu_type_pla, pla_extra_status, ocp_data); + linkmode_mod_bit(ethtool_link_mode_2500baset_full_bit, + cmd->link_modes.supported, tp->support_2500full); + + if (tp->support_2500full) { + linkmode_mod_bit(ethtool_link_mode_2500baset_full_bit, + cmd->link_modes.advertising, + ocp_reg_read(tp, ocp_10gbt_ctrl) & mdio_an_10gbt_ctrl_adv2_5g); + + linkmode_mod_bit(ethtool_link_mode_2500baset_full_bit, + cmd->link_modes.lp_advertising, + ocp_reg_read(tp, ocp_10gbt_stat) & mdio_an_10gbt_stat_lp2_5g); + + if (is_speed_2500(rtl8152_get_speed(tp))) + cmd->base.speed = speed_2500; + } + + if (test_bit(ethtool_link_mode_2500baset_full_bit, + cmd->link_modes.advertising)) + advertising |= rtl_advertised_2500_full; + + case rtl_ver_11: + tp->eee_en = true; + tp->eee_adv = mdio_eee_1000t | mdio_eee_100tx; + fallthrough; + case rtl_ver_10: + ops->init = r8156_init; + ops->enable = rtl8156_enable; + ops->disable = rtl8153_disable; + ops->up = rtl8156_up; + ops->down = rtl8156_down; + ops->unload = rtl8153_unload; + ops->eee_get = r8153_get_eee; + ops->eee_set = r8152_set_eee; + ops->in_nway = rtl8153_in_nway; + ops->hw_phy_cfg = r8156_hw_phy_cfg; + ops->autosuspend_en = rtl8156_runtime_enable; + ops->change_mtu = rtl8156_change_mtu; + tp->rx_buf_sz = 48 * 1024; + tp->support_2500full = 1; + break; + + case rtl_ver_12: + case rtl_ver_13: + tp->support_2500full = 1; + fallthrough; + case rtl_ver_15: + tp->eee_en = true; + tp->eee_adv = mdio_eee_1000t | mdio_eee_100tx; + ops->init = r8156b_init; + ops->enable = rtl8156b_enable; + ops->disable = rtl8153_disable; + ops->up = rtl8156_up; + ops->down = rtl8156_down; + ops->unload = rtl8153_unload; + ops->eee_get = r8153_get_eee; + ops->eee_set = r8152_set_eee; + ops->in_nway = rtl8153_in_nway; + ops->hw_phy_cfg = r8156b_hw_phy_cfg; + ops->autosuspend_en = rtl8156_runtime_enable; + ops->change_mtu = rtl8156_change_mtu; + tp->rx_buf_sz = 48 * 1024; + break; + + case rtl_ver_14: + ops->init = r8153c_init; + ops->enable = rtl8153_enable; + ops->disable = rtl8153_disable; + ops->up = rtl8153c_up; + ops->down = rtl8153b_down; + ops->unload = rtl8153_unload; + ops->eee_get = r8153_get_eee; + ops->eee_set = r8152_set_eee; + ops->in_nway = rtl8153_in_nway; + ops->hw_phy_cfg = r8153c_hw_phy_cfg; + ops->autosuspend_en = rtl8153c_runtime_enable; + ops->change_mtu = rtl8153c_change_mtu; + tp->rx_buf_sz = 32 * 1024; + tp->eee_en = true; + tp->eee_adv = mdio_eee_1000t | mdio_eee_100tx; + break; + +#define firmware_8153c_1 "rtl_nic/rtl8153c-1.fw" +module_firmware(firmware_8153c_1); + case rtl_ver_14: + rtl_fw->fw_name = firmware_8153c_1; + rtl_fw->pre_fw = r8153b_pre_firmware_1; + rtl_fw->post_fw = r8153c_post_firmware_1; + break; + case 0x7010: + version = rtl_test_01; + break; + case 0x7020: + version = rtl_ver_10; + break; + case 0x7030: + version = rtl_ver_11; + break; + case 0x7400: + version = rtl_ver_12; + break; + case 0x7410: + version = rtl_ver_13; + break; + case 0x6400: + version = rtl_ver_14; + break; + case 0x7420: + version = rtl_ver_15; + break; + case rtl_ver_03: + case rtl_ver_04: + case rtl_ver_05: + case rtl_ver_06: + case rtl_ver_08: + case rtl_ver_09: + case rtl_ver_14: + netdev->max_mtu = size_to_mtu(9 * 1024); + break; + case rtl_ver_10: + case rtl_ver_11: + netdev->max_mtu = size_to_mtu(15 * 1024); + break; + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_15: + netdev->max_mtu = size_to_mtu(16 * 1024); + break; - netdev->max_mtu = eth_data_len; - break; + case rtl_ver_07: - netdev->max_mtu = size_to_mtu(9 * 1024); + netdev->max_mtu = eth_data_len; - tp->speed = speed_1000; + if (tp->support_2500full && + tp->udev->speed >= usb_speed_super) { + tp->speed = speed_2500; + tp->advertising |= rtl_advertised_2500_full; + } else { + tp->speed = speed_1000; + } - netif_napi_add(netdev, &tp->napi, r8152_poll, rtl8152_napi_weight); + + if (tp->support_2500full) + netif_napi_add(netdev, &tp->napi, r8152_poll, 256); + else + netif_napi_add(netdev, &tp->napi, r8152_poll, 64); - tp->rtl_ops.unload(tp); + if (tp->rtl_ops.unload) + tp->rtl_ops.unload(tp); + .binterfaceprotocol = usb_cdc_proto_none \ +}, \ +{ \ + .match_flags = usb_device_id_match_int_info | \ + usb_device_id_match_device, \ + .idvendor = (vend), \ + .idproduct = (prod), \ + .binterfaceclass = usb_class_comm, \ + .binterfacesubclass = usb_cdc_subclass_ncm, \ + /* realtek */ + {realtek_usb_device(vendor_id_realtek, 0x8053)}, + {realtek_usb_device(vendor_id_realtek, 0x8155)}, + {realtek_usb_device(vendor_id_realtek, 0x8156)}, + + /* microsoft */
|
Networking
|
195aae321c829dd1945900d75561e6aa79cce208
|
hayes wang
|
drivers
|
net
|
usb
|
r8152: support phy firmware for rtl8156 series
|
support new firmware type and method for rtl8156 series.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
support new chips
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['r8152']
|
['c']
| 1
| 561
| 2
|
--- diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c + fw_flags_nc1, + fw_flags_nc2, + fw_flags_uc2, + fw_flags_uc, + fw_flags_speed_up, + fw_flags_ver, +enum rtl8152_fw_fixup_cmd { + fw_fixup_and = 0, + fw_fixup_or, + fw_fixup_not, + fw_fixup_xor, +}; + +struct fw_phy_set { + __le16 addr; + __le16 data; +} __packed; + +struct fw_phy_speed_up { + struct fw_block blk_hdr; + __le16 fw_offset; + __le16 version; + __le16 fw_reg; + __le16 reserved; + char info[]; +} __packed; + +struct fw_phy_ver { + struct fw_block blk_hdr; + struct fw_phy_set ver; + __le32 reserved; +} __packed; + +struct fw_phy_fixup { + struct fw_block blk_hdr; + struct fw_phy_set setting; + __le16 bit_cmd; + __le16 reserved; +} __packed; + +struct fw_phy_union { + struct fw_block blk_hdr; + __le16 fw_offset; + __le16 fw_reg; + struct fw_phy_set pre_set[2]; + struct fw_phy_set bp[8]; + struct fw_phy_set bp_en; + u8 pre_num; + u8 bp_num; + char info[]; +} __packed; + + rtl_fw_phy_fixup, + rtl_fw_phy_union_nc, + rtl_fw_phy_union_nc1, + rtl_fw_phy_union_nc2, + rtl_fw_phy_union_uc2, + rtl_fw_phy_union_uc, + rtl_fw_phy_union_misc, + rtl_fw_phy_speed_up, + rtl_fw_phy_ver, +static bool rtl8152_is_fw_phy_speed_up_ok(struct r8152 *tp, struct fw_phy_speed_up *phy) +{ + u16 fw_offset; + u32 length; + bool rc = false; + + switch (tp->version) { + case rtl_ver_01: + case rtl_ver_02: + case rtl_ver_03: + case rtl_ver_04: + case rtl_ver_05: + case rtl_ver_06: + case rtl_ver_07: + case rtl_ver_08: + case rtl_ver_09: + case rtl_ver_10: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_14: + goto out; + case rtl_ver_13: + case rtl_ver_15: + default: + break; + } + + fw_offset = __le16_to_cpu(phy->fw_offset); + length = __le32_to_cpu(phy->blk_hdr.length); + if (fw_offset < sizeof(*phy) || length <= fw_offset) { + dev_err(&tp->intf->dev, "invalid fw_offset "); + goto out; + } + + length -= fw_offset; + if (length & 3) { + dev_err(&tp->intf->dev, "invalid block length "); + goto out; + } + + if (__le16_to_cpu(phy->fw_reg) != 0x9a00) { + dev_err(&tp->intf->dev, "invalid register to load firmware "); + goto out; + } + + rc = true; +out: + return rc; +} + +static bool rtl8152_is_fw_phy_ver_ok(struct r8152 *tp, struct fw_phy_ver *ver) +{ + bool rc = false; + + switch (tp->version) { + case rtl_ver_10: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_15: + break; + default: + goto out; + } + + if (__le32_to_cpu(ver->blk_hdr.length) != sizeof(*ver)) { + dev_err(&tp->intf->dev, "invalid block length "); + goto out; + } + + if (__le16_to_cpu(ver->ver.addr) != sram_gphy_fw_ver) { + dev_err(&tp->intf->dev, "invalid phy ver addr "); + goto out; + } + + rc = true; +out: + return rc; +} + +static bool rtl8152_is_fw_phy_fixup_ok(struct r8152 *tp, struct fw_phy_fixup *fix) +{ + bool rc = false; + + switch (tp->version) { + case rtl_ver_10: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_15: + break; + default: + goto out; + } + + if (__le32_to_cpu(fix->blk_hdr.length) != sizeof(*fix)) { + dev_err(&tp->intf->dev, "invalid block length "); + goto out; + } + + if (__le16_to_cpu(fix->setting.addr) != ocp_phy_patch_cmd || + __le16_to_cpu(fix->setting.data) != bit(7)) { + dev_err(&tp->intf->dev, "invalid phy fixup "); + goto out; + } + + rc = true; +out: + return rc; +} + +static bool rtl8152_is_fw_phy_union_ok(struct r8152 *tp, struct fw_phy_union *phy) +{ + u16 fw_offset; + u32 length; + bool rc = false; + + switch (tp->version) { + case rtl_ver_10: + case rtl_ver_11: + case rtl_ver_12: + case rtl_ver_13: + case rtl_ver_15: + break; + default: + goto out; + } + + fw_offset = __le16_to_cpu(phy->fw_offset); + length = __le32_to_cpu(phy->blk_hdr.length); + if (fw_offset < sizeof(*phy) || length <= fw_offset) { + dev_err(&tp->intf->dev, "invalid fw_offset "); + goto out; + } + + length -= fw_offset; + if (length & 1) { + dev_err(&tp->intf->dev, "invalid block length "); + goto out; + } + + if (phy->pre_num > 2) { + dev_err(&tp->intf->dev, "invalid pre_num %d ", phy->pre_num); + goto out; + } + + if (phy->bp_num > 8) { + dev_err(&tp->intf->dev, "invalid bp_num %d ", phy->bp_num); + goto out; + } + + rc = true; +out: + return rc; +} + + test_bit(fw_flags_nc1, &fw_flags) || + test_bit(fw_flags_nc2, &fw_flags) || + test_bit(fw_flags_uc2, &fw_flags) || + test_bit(fw_flags_uc, &fw_flags) || + break; + case rtl_fw_phy_union_nc: + if (!test_bit(fw_flags_start, &fw_flags) || + test_bit(fw_flags_nc1, &fw_flags) || + test_bit(fw_flags_nc2, &fw_flags) || + test_bit(fw_flags_uc2, &fw_flags) || + test_bit(fw_flags_uc, &fw_flags) || + test_bit(fw_flags_stop, &fw_flags)) { + dev_err(&tp->intf->dev, "phy_union_nc out of order "); + goto fail; + } + + if (test_bit(fw_flags_nc, &fw_flags)) { + dev_err(&tp->intf->dev, "multiple phy_union_nc encountered "); + goto fail; + } + + if (!rtl8152_is_fw_phy_union_ok(tp, (struct fw_phy_union *)block)) { + dev_err(&tp->intf->dev, "check phy_union_nc failed "); + goto fail; + } + __set_bit(fw_flags_nc, &fw_flags); + break; + case rtl_fw_phy_union_nc1: + if (!test_bit(fw_flags_start, &fw_flags) || + test_bit(fw_flags_nc2, &fw_flags) || + test_bit(fw_flags_uc2, &fw_flags) || + test_bit(fw_flags_uc, &fw_flags) || + test_bit(fw_flags_stop, &fw_flags)) { + dev_err(&tp->intf->dev, "phy_union_nc1 out of order "); + goto fail; + } + + if (test_bit(fw_flags_nc1, &fw_flags)) { + dev_err(&tp->intf->dev, "multiple phy nc1 encountered "); + goto fail; + } + + if (!rtl8152_is_fw_phy_union_ok(tp, (struct fw_phy_union *)block)) { + dev_err(&tp->intf->dev, "check phy_union_nc1 failed "); + goto fail; + } + __set_bit(fw_flags_nc1, &fw_flags); + break; + case rtl_fw_phy_union_nc2: + if (!test_bit(fw_flags_start, &fw_flags) || + test_bit(fw_flags_uc2, &fw_flags) || + test_bit(fw_flags_uc, &fw_flags) || + test_bit(fw_flags_stop, &fw_flags)) { + dev_err(&tp->intf->dev, "phy_union_nc2 out of order "); + goto fail; + } + + if (test_bit(fw_flags_nc2, &fw_flags)) { + dev_err(&tp->intf->dev, "multiple phy nc2 encountered "); + goto fail; + } + + if (!rtl8152_is_fw_phy_union_ok(tp, (struct fw_phy_union *)block)) { + dev_err(&tp->intf->dev, "check phy_union_nc2 failed "); + goto fail; + } + __set_bit(fw_flags_nc2, &fw_flags); + break; + case rtl_fw_phy_union_uc2: + if (!test_bit(fw_flags_start, &fw_flags) || + test_bit(fw_flags_uc, &fw_flags) || + test_bit(fw_flags_stop, &fw_flags)) { + dev_err(&tp->intf->dev, "phy_union_uc2 out of order "); + goto fail; + } + + if (test_bit(fw_flags_uc2, &fw_flags)) { + dev_err(&tp->intf->dev, "multiple phy uc2 encountered "); + goto fail; + } + + if (!rtl8152_is_fw_phy_union_ok(tp, (struct fw_phy_union *)block)) { + dev_err(&tp->intf->dev, "check phy_union_uc2 failed "); + goto fail; + } + __set_bit(fw_flags_uc2, &fw_flags); + break; + case rtl_fw_phy_union_uc: + if (!test_bit(fw_flags_start, &fw_flags) || + test_bit(fw_flags_stop, &fw_flags)) { + dev_err(&tp->intf->dev, "phy_union_uc out of order "); + goto fail; + } + + if (test_bit(fw_flags_uc, &fw_flags)) { + dev_err(&tp->intf->dev, "multiple phy uc encountered "); + goto fail; + } + + if (!rtl8152_is_fw_phy_union_ok(tp, (struct fw_phy_union *)block)) { + dev_err(&tp->intf->dev, "check phy_union_uc failed "); + goto fail; + } + __set_bit(fw_flags_uc, &fw_flags); + break; + case rtl_fw_phy_union_misc: + if (!rtl8152_is_fw_phy_union_ok(tp, (struct fw_phy_union *)block)) { + dev_err(&tp->intf->dev, "check rtl_fw_phy_union_misc failed "); + goto fail; + } + break; + case rtl_fw_phy_fixup: + if (!rtl8152_is_fw_phy_fixup_ok(tp, (struct fw_phy_fixup *)block)) { + dev_err(&tp->intf->dev, "check phy fixup failed "); + goto fail; + } + break; + case rtl_fw_phy_speed_up: + if (test_bit(fw_flags_speed_up, &fw_flags)) { + dev_err(&tp->intf->dev, "multiple phy firmware encountered"); + goto fail; + } + if (!rtl8152_is_fw_phy_speed_up_ok(tp, (struct fw_phy_speed_up *)block)) { + dev_err(&tp->intf->dev, "check phy speed up failed "); + goto fail; + } + __set_bit(fw_flags_speed_up, &fw_flags); + break; + case rtl_fw_phy_ver: + if (test_bit(fw_flags_start, &fw_flags) || + test_bit(fw_flags_nc, &fw_flags) || + test_bit(fw_flags_nc1, &fw_flags) || + test_bit(fw_flags_nc2, &fw_flags) || + test_bit(fw_flags_uc2, &fw_flags) || + test_bit(fw_flags_uc, &fw_flags) || + test_bit(fw_flags_stop, &fw_flags)) { + dev_err(&tp->intf->dev, "invalid order to set phy version "); + goto fail; + } + + if (test_bit(fw_flags_ver, &fw_flags)) { + dev_err(&tp->intf->dev, "multiple phy version encountered"); + goto fail; + } + + if (!rtl8152_is_fw_phy_ver_ok(tp, (struct fw_phy_ver *)block)) { + dev_err(&tp->intf->dev, "check phy version failed "); + goto fail; + } + __set_bit(fw_flags_ver, &fw_flags); +static void rtl_ram_code_speed_up(struct r8152 *tp, struct fw_phy_speed_up *phy, bool wait) +{ + u32 len; + u8 *data; + + if (sram_read(tp, sram_gphy_fw_ver) >= __le16_to_cpu(phy->version)) { + dev_dbg(&tp->intf->dev, "phy firmware has been the newest "); + return; + } + + len = __le32_to_cpu(phy->blk_hdr.length); + len -= __le16_to_cpu(phy->fw_offset); + data = (u8 *)phy + __le16_to_cpu(phy->fw_offset); + + if (rtl_phy_patch_request(tp, true, wait)) + return; + + while (len) { + u32 ocp_data, size; + int i; + + if (len < 2048) + size = len; + else + size = 2048; + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_gphy_ctrl); + ocp_data |= gphy_patch_done | backup_restrore; + ocp_write_word(tp, mcu_type_usb, usb_gphy_ctrl, ocp_data); + + generic_ocp_write(tp, __le16_to_cpu(phy->fw_reg), 0xff, size, data, mcu_type_usb); + + data += size; + len -= size; + + ocp_data = ocp_read_word(tp, mcu_type_pla, pla_pol_gpio_ctrl); + ocp_data |= pol_gphy_patch; + ocp_write_word(tp, mcu_type_pla, pla_pol_gpio_ctrl, ocp_data); + + for (i = 0; i < 1000; i++) { + if (!(ocp_read_word(tp, mcu_type_pla, pla_pol_gpio_ctrl) & pol_gphy_patch)) + break; + } + + if (i == 1000) { + dev_err(&tp->intf->dev, "ram code speedup mode timeout "); + return; + } + } + + ocp_write_word(tp, mcu_type_pla, pla_ocp_gphy_base, tp->ocp_base); + rtl_phy_patch_request(tp, false, wait); + + if (sram_read(tp, sram_gphy_fw_ver) == __le16_to_cpu(phy->version)) + dev_dbg(&tp->intf->dev, "successfully applied %s ", phy->info); + else + dev_err(&tp->intf->dev, "ram code speedup mode fail "); +} + +static int rtl8152_fw_phy_ver(struct r8152 *tp, struct fw_phy_ver *phy_ver) +{ + u16 ver_addr, ver; + + ver_addr = __le16_to_cpu(phy_ver->ver.addr); + ver = __le16_to_cpu(phy_ver->ver.data); + + if (sram_read(tp, ver_addr) >= ver) { + dev_dbg(&tp->intf->dev, "phy firmware has been the newest "); + return 0; + } + + sram_write(tp, ver_addr, ver); + + dev_dbg(&tp->intf->dev, "phy firmware version %x ", ver); + + return ver; +} + +static void rtl8152_fw_phy_fixup(struct r8152 *tp, struct fw_phy_fixup *fix) +{ + u16 addr, data; + + addr = __le16_to_cpu(fix->setting.addr); + data = ocp_reg_read(tp, addr); + + switch (__le16_to_cpu(fix->bit_cmd)) { + case fw_fixup_and: + data &= __le16_to_cpu(fix->setting.data); + break; + case fw_fixup_or: + data |= __le16_to_cpu(fix->setting.data); + break; + case fw_fixup_not: + data &= ~__le16_to_cpu(fix->setting.data); + break; + case fw_fixup_xor: + data ^= __le16_to_cpu(fix->setting.data); + break; + default: + return; + } + + ocp_reg_write(tp, addr, data); + + dev_dbg(&tp->intf->dev, "applied ocp %x %x ", addr, data); +} + +static void rtl8152_fw_phy_union_apply(struct r8152 *tp, struct fw_phy_union *phy) +{ + __le16 *data; + u32 length; + int i, num; + + num = phy->pre_num; + for (i = 0; i < num; i++) + sram_write(tp, __le16_to_cpu(phy->pre_set[i].addr), + __le16_to_cpu(phy->pre_set[i].data)); + + length = __le32_to_cpu(phy->blk_hdr.length); + length -= __le16_to_cpu(phy->fw_offset); + num = length / 2; + data = (__le16 *)((u8 *)phy + __le16_to_cpu(phy->fw_offset)); + + ocp_reg_write(tp, ocp_sram_addr, __le16_to_cpu(phy->fw_reg)); + for (i = 0; i < num; i++) + ocp_reg_write(tp, ocp_sram_data, __le16_to_cpu(data[i])); + + num = phy->bp_num; + for (i = 0; i < num; i++) + sram_write(tp, __le16_to_cpu(phy->bp[i].addr), __le16_to_cpu(phy->bp[i].data)); + + if (phy->bp_num && phy->bp_en.addr) + sram_write(tp, __le16_to_cpu(phy->bp_en.addr), __le16_to_cpu(phy->bp_en.data)); + + dev_dbg(&tp->intf->dev, "successfully applied %s ", phy->info); +} + + fw_ver_reg = __le16_to_cpu(mac->fw_ver_reg); + if (fw_ver_reg && ocp_read_byte(tp, mcu_type_usb, fw_ver_reg) >= mac->fw_ver_data) { + dev_dbg(&tp->intf->dev, "%s firmware has been the newest ", type ? "pla" : "usb"); + return; + } + - fw_ver_reg = __le16_to_cpu(mac->fw_ver_reg); - int i; + int i, patch_phy = 1; + if (!patch_phy) + break; + if (!patch_phy) + break; + case rtl_fw_phy_ver: + patch_phy = rtl8152_fw_phy_ver(tp, (struct fw_phy_ver *)block); + break; + case rtl_fw_phy_union_nc: + case rtl_fw_phy_union_nc1: + case rtl_fw_phy_union_nc2: + case rtl_fw_phy_union_uc2: + case rtl_fw_phy_union_uc: + case rtl_fw_phy_union_misc: + if (patch_phy) + rtl8152_fw_phy_union_apply(tp, (struct fw_phy_union *)block); + break; + case rtl_fw_phy_fixup: + if (patch_phy) + rtl8152_fw_phy_fixup(tp, (struct fw_phy_fixup *)block); + break; + case rtl_fw_phy_speed_up: + rtl_ram_code_speed_up(tp, (struct fw_phy_speed_up *)block, !power_cut); + break; +static int r8156a_post_firmware_1(struct r8152 *tp) +{ + u32 ocp_data; + + ocp_data = ocp_read_word(tp, mcu_type_usb, usb_fw_fix_en1); + ocp_data |= fw_ip_reset_en; + ocp_write_word(tp, mcu_type_usb, usb_fw_fix_en1, ocp_data); + + /* modify u3phy parameter for compatibility issue */ + ocp_write_dword(tp, mcu_type_usb, usb_uphy3_mdcmdio, 0x4026840e); + ocp_write_dword(tp, mcu_type_usb, usb_uphy3_mdcmdio, 0x4001acc9); + + return 0; +} + +#define firmware_8156a_2 "rtl_nic/rtl8156a-2.fw" +#define firmware_8156b_2 "rtl_nic/rtl8156b-2.fw" +module_firmware(firmware_8156a_2); +module_firmware(firmware_8156b_2); + case rtl_ver_11: + rtl_fw->fw_name = firmware_8156a_2; + rtl_fw->post_fw = r8156a_post_firmware_1; + break; + case rtl_ver_13: + case rtl_ver_15: + rtl_fw->fw_name = firmware_8156b_2; + break;
|
Networking
|
4a51b0e8a0143b0e83d51d9c58c6416c3818a9f2
|
hayes wang
|
drivers
|
net
|
usb
|
r8152: search the configuration of vendor mode
|
the vendor mode is not always at config #1, so it is necessary to set the correct configuration number.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
support new chips
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['r8152']
|
['c']
| 1
| 35
| 4
|
--- diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c -#define netnext_version "11" +#define netnext_version "12" +static bool rtl_vendor_mode(struct usb_interface *intf) +{ + struct usb_host_interface *alt = intf->cur_altsetting; + struct usb_device *udev; + struct usb_host_config *c; + int i, num_configs; + + if (alt->desc.binterfaceclass == usb_class_vendor_spec) + return true; + + /* the vendor mode is not always config #1, so to find it out. */ + udev = interface_to_usbdev(intf); + c = udev->config; + num_configs = udev->descriptor.bnumconfigurations; + for (i = 0; i < num_configs; (i++, c++)) { + struct usb_interface_descriptor *desc = null; + + if (c->desc.bnuminterfaces > 0) + desc = &c->intf_cache[0]->altsetting->desc; + else + continue; + + if (desc->binterfaceclass == usb_class_vendor_spec) { + usb_driver_set_configuration(udev, c->desc.bconfigurationvalue); + break; + } + } + + warn_on_once(i == num_configs); + + return false; +} + - if (udev->actconfig->desc.bconfigurationvalue != 1) { - usb_driver_set_configuration(udev, 1); + if (!rtl_vendor_mode(intf)) - }
|
Networking
|
c2198943e33b100ed21dfb636c8fa6baef841e9d
|
hayes wang
|
drivers
|
net
|
usb
|
r8169: add support for ethtool get_ringparam
|
add support for the ethtool get_ringparam operation.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for ethtool get_ringparam
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['r8169 ']
|
['c']
| 1
| 10
| 0
|
--- diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c +static void rtl8169_get_ringparam(struct net_device *dev, + struct ethtool_ringparam *data) +{ + data->rx_max_pending = num_rx_desc; + data->rx_pending = num_rx_desc; + data->tx_max_pending = num_tx_desc; + data->tx_pending = num_tx_desc; +} + + .get_ringparam = rtl8169_get_ringparam,
|
Networking
|
dc4aa50b13f1d33fdd813b56bb414714268025ad
|
heiner kallweit
|
drivers
|
net
|
ethernet, realtek
|
r8169: add support for pause ethtool ops
|
this adds support for the [g|s]et_pauseparam ethtool ops. it considers that the chip doesn't support pause frame use in jumbo mode.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for pause ethtool ops
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['r8169 ']
|
['c']
| 1
| 28
| 0
|
--- diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c +static void rtl8169_get_pauseparam(struct net_device *dev, + struct ethtool_pauseparam *data) +{ + struct rtl8169_private *tp = netdev_priv(dev); + bool tx_pause, rx_pause; + + phy_get_pause(tp->phydev, &tx_pause, &rx_pause); + + data->autoneg = tp->phydev->autoneg; + data->tx_pause = tx_pause ? 1 : 0; + data->rx_pause = rx_pause ? 1 : 0; +} + +static int rtl8169_set_pauseparam(struct net_device *dev, + struct ethtool_pauseparam *data) +{ + struct rtl8169_private *tp = netdev_priv(dev); + + if (dev->mtu > eth_data_len) + return -eopnotsupp; + + phy_set_asym_pause(tp->phydev, data->rx_pause, data->tx_pause); + + return 0; +} + + .get_pauseparam = rtl8169_get_pauseparam, + .set_pauseparam = rtl8169_set_pauseparam,
|
Networking
|
216f78ea8cf6fae5140aeb55657ebdab71a05502
|
heiner kallweit
|
drivers
|
net
|
ethernet, realtek
|
rtw88: 8822c: reorder macro position according to the register number
|
this patch doesn't change logic at all, just a refactor patch.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add gapk
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88 ', '8822c']
|
['h', 'c']
| 2
| 148
| 143
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c - rtw_write_rf(rtwdev, path, 0x60, rf_pabias_2g_mask, pg_pa_bias); + rtw_write_rf(rtwdev, path, rf_pa, rf_pabias_2g_mask, pg_pa_bias); - rtw_write_rf(rtwdev, path, 0x60, rf_pabias_5g_mask, pg_pa_bias); + rtw_write_rf(rtwdev, path, rf_pa, rf_pabias_5g_mask, pg_pa_bias); - rtw_write32(rtwdev, reg_dpd_lut3, 0x1f100000); + rtw_write32(rtwdev, reg_dpd_ctl1_s1, 0x1f100000); - rtw_write32(rtwdev, reg_dpd_lut3, 0x1f0d0000); + rtw_write32(rtwdev, reg_dpd_ctl1_s1, 0x1f0d0000); - rtw_write_rf(rtwdev, path, rf_tx_gain_offset, bit_tx_offset_val, 0x0); + rtw_write_rf(rtwdev, path, rf_tx_gain_offset, bit_bb_gain, 0x0); - rtw_write_rf(rtwdev, path, rf_tx_gain_offset, bit_lb_att, 0x1); + rtw_write_rf(rtwdev, path, rf_tx_gain_offset, bit_rf_gain, 0x1); - rtw_write32(rtwdev, reg_dpd_lut3, 0x1f100000); + rtw_write32(rtwdev, reg_dpd_ctl1_s1, 0x1f100000); - rtw_write32(rtwdev, reg_dpd_lut3, 0x1f0d0000); + rtw_write32(rtwdev, reg_dpd_ctl1_s1, 0x1f0d0000); diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.h b/drivers/net/wireless/realtek/rtw88/rtw8822c.h --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.h - -#define reg_txdfir0 0x808 -#define reg_dfirbw 0x810 -#define reg_antmap0 0x820 -#define reg_antmap 0x824 -#define reg_dymprith 0x86c -#define reg_dymenth0 0x870 -#define reg_dymenth 0x874 -#define reg_sbd 0x88c +#define reg_txdfir0 0x808 +#define reg_dfirbw 0x810 +#define reg_antmap0 0x820 +#define reg_antmap 0x824 +#define reg_dymprith 0x86c +#define reg_dymenth0 0x870 +#define reg_dymenth 0x874 +#define reg_sbd 0x88c -#define reg_dymthmin 0x8a4 -#define reg_txbwctl 0x9b0 -#define reg_txclk 0x9b4 -#define reg_scotrk 0xc30 -#define reg_mrcm 0xc38 -#define reg_agcswsh 0xc44 -#define reg_antwtpd 0xc54 -#define reg_pt_chsmo 0xcbc +#define reg_dymthmin 0x8a4 + +#define reg_txbwctl 0x9b0 +#define reg_txclk 0x9b4 + +#define reg_scotrk 0xc30 +#define reg_mrcm 0xc38 +#define reg_agcswsh 0xc44 +#define reg_antwtpd 0xc54 +#define reg_pt_chsmo 0xcbc -#define reg_oritxcode 0x1800 -#define reg_3wire 0x180c + +#define reg_oritxcode 0x1800 +#define reg_3wire 0x180c -#define reg_anapar_a 0x1830 +#define reg_anapar_a 0x1830 -#define reg_rxagcctl0 0x18ac +#define reg_rxagcctl0 0x18ac -#define reg_dcka_i_0 0x18bc -#define reg_dcka_i_1 0x18c0 -#define reg_dcka_q_0 0x18d8 -#define reg_dcka_q_1 0x18dc -#define reg_ccksb 0x1a00 -#define reg_rxccksel 0x1a04 -#define reg_bgctrl 0x1a14 +#define reg_dcka_i_0 0x18bc +#define reg_dcka_i_1 0x18c0 +#define reg_dcka_q_0 0x18d8 +#define reg_dcka_q_1 0x18dc + +#define reg_ccksb 0x1a00 +#define reg_rxccksel 0x1a04 +#define reg_bgctrl 0x1a14 -#define reg_txf0 0x1a20 -#define reg_txf1 0x1a24 -#define reg_txf2 0x1a28 -#define reg_ccanrx 0x1a2c +#define reg_txf0 0x1a20 +#define reg_txf1 0x1a24 +#define reg_txf2 0x1a28 +#define reg_ccanrx 0x1a2c -#define reg_cck_facnt 0x1a5c -#define reg_ccktxonly 0x1a80 +#define reg_cck_facnt 0x1a5c +#define reg_ccktxonly 0x1a80 -#define reg_txf3 0x1a98 -#define reg_txf4 0x1a9c -#define reg_txf5 0x1aa0 -#define reg_txf6 0x1aac -#define reg_txf7 0x1ab0 -#define reg_cck_source 0x1abc +#define reg_txf3 0x1a98 +#define reg_txf4 0x1a9c +#define reg_txf5 0x1aa0 +#define reg_txf6 0x1aac +#define reg_txf7 0x1ab0 +#define reg_cck_source 0x1abc -#define reg_iqkstat 0x1b10 -#define reg_txant 0x1c28 -#define reg_encck 0x1c3c -#define bit_cck_blk_en bit(1) -#define bit_cck_ofdm_blk_en (bit(0) | bit(1)) -#define reg_ccamsk 0x1c80 -#define reg_rstb 0x1c90 -#define bit_rstb_3wire bit(8) -#define reg_rx_break 0x1d2c -#define bit_com_rx_gck_en bit(31) -#define reg_rxfnctl 0x1d30 -#define reg_rxigi 0x1d70 -#define reg_enfn 0x1e24 -#define reg_txantseg 0x1e28 -#define reg_txlgmap 0x1e2c -#define reg_cckpath 0x1e5c -#define reg_cnt_ctrl 0x1eb4 -#define bit_all_cnt_rst bit(25) -#define reg_ofdm_facnt 0x2d00 -#define reg_ofdm_facnt1 0x2d04 -#define reg_ofdm_facnt2 0x2d08 -#define reg_ofdm_facnt3 0x2d0c -#define reg_ofdm_facnt4 0x2d10 -#define reg_ofdm_facnt5 0x2d20 -#define reg_rpt_cip 0x2d9c -#define reg_ofdm_txcnt 0x2de0 -#define reg_oritxcode2 0x4100 -#define reg_3wire2 0x410c -#define reg_anapar_b 0x4130 -#define reg_rxagcctl 0x41ac -#define reg_dckb_i_0 0x41bc -#define reg_dckb_i_1 0x41c0 -#define reg_dckb_q_0 0x41d8 -#define reg_dckb_q_1 0x41dc - -#define rf_mode_trxagc 0x00 -#define rf_rxagc_offset 0x19 -#define rf_bw_trxbb 0x1a -#define rf_tx_gain_offset 0x55 -#define rf_tx_gain 0x56 -#define rf_txa_lb_sw 0x63 -#define rf_rxg_gain 0x87 -#define rf_rxa_mix_gain 0x8a -#define rf_ext_tia_bw 0x8f -#define rf_debug 0xde +#define bit_subpage genmask(3, 0) +#define bit_gs_pwsf genmask(27, 0) +#define bit_dpd_en bit(31) +#define reg_iqkstat 0x1b10 +#define bit_bypass_dpd bit(25) +#define bit_tx_cfir genmask(31, 30) +#define bit_gloss_db genmask(14, 12) -#define reg_dpd_lut3 0x1b60 +#define bit_inner_lb bit(21) +#define bit_iq_switch genmask(5, 0) +#define bit_rpt_sel genmask(20, 16) +#define bit_dpd_clk genmask(7, 4) +#define bit_rpt_dgain genmask(27, 16) -#define bit_ext_tia_bw bit(1) -#define bit_de_trxbw bit(2) -#define bit_de_tx_gain bit(16) -#define bit_rxg_gain bit(18) -#define bit_de_pwr_trim bit(19) -#define bit_inner_lb bit(21) -#define bit_bypass_dpd bit(25) -#define bit_dpd_en bit(31) -#define bit_subpage genmask(3, 0) +#define reg_txant 0x1c28 +#define reg_encck 0x1c3c +#define bit_cck_blk_en bit(1) +#define bit_cck_ofdm_blk_en (bit(0) | bit(1)) +#define reg_ccamsk 0x1c80 +#define reg_rstb 0x1c90 +#define bit_rstb_3wire bit(8) + +#define reg_rx_break 0x1d2c +#define bit_com_rx_gck_en bit(31) +#define reg_rxfnctl 0x1d30 +#define reg_rxigi 0x1d70 +#define reg_enfn 0x1e24 +#define reg_txantseg 0x1e28 +#define reg_txlgmap 0x1e2c +#define reg_cckpath 0x1e5c +#define reg_cnt_ctrl 0x1eb4 +#define bit_all_cnt_rst bit(25) + +#define reg_ofdm_facnt 0x2d00 +#define reg_ofdm_facnt1 0x2d04 +#define reg_ofdm_facnt2 0x2d08 +#define reg_ofdm_facnt3 0x2d0c +#define reg_ofdm_facnt4 0x2d10 +#define reg_ofdm_facnt5 0x2d20 +#define reg_rpt_cip 0x2d9c +#define reg_ofdm_txcnt 0x2de0 + +#define reg_oritxcode2 0x4100 +#define reg_3wire2 0x410c +#define reg_anapar_b 0x4130 +#define reg_rxagcctl 0x41ac +#define reg_dckb_i_0 0x41bc +#define reg_dckb_i_1 0x41c0 +#define reg_dckb_q_0 0x41d8 +#define reg_dckb_q_1 0x41dc + +#define rf_mode_trxagc 0x00 +#define bit_rxagc genmask(9, 5) +#define rf_rxagc_offset 0x19 +#define rf_bw_trxbb 0x1a +#define bit_bw_txbb genmask(14, 12) +#define bit_bw_rxbb genmask(11, 10) +#define rf_tx_gain_offset 0x55 +#define bit_bb_gain genmask(18, 14) +#define bit_rf_gain genmask(4, 2) +#define rf_tx_gain 0x56 +#define rf_pa 0x60 +#define rf_pabias_2g_mask genmask(15, 12) +#define rf_pabias_5g_mask genmask(19, 16) +#define rf_txa_lb_sw 0x63 +#define bit_txa_lb_att genmask(15, 14) +#define bit_lb_sw genmask(13, 12) +#define rf_rxg_gain 0x87 +#define bit_rxg_gain bit(18) +#define rf_rxa_mix_gain 0x8a -#define bit_iq_switch genmask(5, 0) -#define bit_dpd_clk genmask(7, 4) -#define bit_rxagc genmask(9, 5) -#define bit_bw_rxbb genmask(11, 10) -#define bit_lb_sw genmask(13, 12) -#define bit_bw_txbb genmask(14, 12) -#define bit_gloss_db genmask(14, 12) -#define bit_txa_lb_att genmask(15, 14) -#define bit_tx_offset_val genmask(18, 14) -#define bit_rpt_sel genmask(20, 16) -#define bit_gs_pwsf genmask(27, 0) -#define bit_rpt_dgain genmask(27, 16) -#define bit_tx_cfir genmask(31, 30) - -#define ppg_thermal_a 0x1ef -#define ppg_thermal_b 0x1b0 -#define rf_themal_mask genmask(19, 16) -#define ppg_2gl_txab 0x1d4 -#define ppg_2gm_txab 0x1ee -#define ppg_2gh_txab 0x1d2 -#define ppg_2g_a_mask genmask(3, 0) -#define ppg_2g_b_mask genmask(7, 4) -#define ppg_5gl1_txa 0x1ec -#define ppg_5gl2_txa 0x1e8 -#define ppg_5gm1_txa 0x1e4 -#define ppg_5gm2_txa 0x1e0 -#define ppg_5gh1_txa 0x1dc -#define ppg_5gl1_txb 0x1eb -#define ppg_5gl2_txb 0x1e7 -#define ppg_5gm1_txb 0x1e3 -#define ppg_5gm2_txb 0x1df -#define ppg_5gh1_txb 0x1db -#define ppg_5g_mask genmask(4, 0) -#define ppg_pabias_2ga 0x1d6 -#define ppg_pabias_2gb 0x1d5 -#define ppg_pabias_5ga 0x1d8 -#define ppg_pabias_5gb 0x1d7 -#define ppg_pabias_mask genmask(3, 0) -#define rf_pabias_2g_mask genmask(15, 12) -#define rf_pabias_5g_mask genmask(19, 16) +#define rf_ext_tia_bw 0x8f +#define rf_debug 0xde +#define bit_de_pwr_trim bit(19) +#define bit_de_tx_gain bit(16) +#define bit_de_trxbw bit(2) +#define ppg_thermal_b 0x1b0 +#define rf_themal_mask genmask(19, 16) +#define ppg_2gh_txab 0x1d2 +#define ppg_2g_a_mask genmask(3, 0) +#define ppg_2g_b_mask genmask(7, 4) +#define ppg_2gl_txab 0x1d4 +#define ppg_pabias_2gb 0x1d5 +#define ppg_pabias_2ga 0x1d6 +#define ppg_pabias_mask genmask(3, 0) +#define ppg_pabias_5gb 0x1d7 +#define ppg_pabias_5ga 0x1d8 +#define ppg_5g_mask genmask(4, 0) +#define ppg_5gh1_txb 0x1db +#define ppg_5gh1_txa 0x1dc +#define ppg_5gm2_txb 0x1df +#define ppg_5gm2_txa 0x1e0 +#define ppg_5gm1_txb 0x1e3 +#define ppg_5gm1_txa 0x1e4 +#define ppg_5gl2_txb 0x1e7 +#define ppg_5gl2_txa 0x1e8 +#define ppg_5gl1_txb 0x1eb +#define ppg_5gl1_txa 0x1ec +#define ppg_2gm_txab 0x1ee +#define ppg_thermal_a 0x1ef
|
Networking
|
f98bf9ee63122d91ab93bfd549c5dd73bf0fd55e
|
guo feng fan
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: 8822c: add gap-k calibration to improve long range performance
|
gap-k is a calibration mechanism to eliminate power gaps between two nearly rate groups.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add gapk
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88 ', '8822c']
|
['h', 'c']
| 6
| 809
| 1
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c --- a/drivers/net/wireless/realtek/rtw88/fw.c +++ b/drivers/net/wireless/realtek/rtw88/fw.c +void rtw_fw_inform_rfk_status(struct rtw_dev *rtwdev, bool start) +{ + u8 h2c_pkt[h2c_pkt_size] = {0}; + + set_h2c_cmd_id_class(h2c_pkt, h2c_cmd_wifi_calibration); + + rfk_set_inform_start(h2c_pkt, start); + + rtw_fw_send_h2c_command(rtwdev, h2c_pkt); +} +export_symbol(rtw_fw_inform_rfk_status); + diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h --- a/drivers/net/wireless/realtek/rtw88/fw.h +++ b/drivers/net/wireless/realtek/rtw88/fw.h +#define h2c_cmd_wifi_calibration 0x6d + +#define rfk_set_inform_start(h2c_pkt, value) \ + le32p_replace_bits((__le32 *)(h2c_pkt) + 0x00, value, bit(8)) +void rtw_fw_inform_rfk_status(struct rtw_dev *rtwdev, bool start); diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h +enum rtw_rf_band { + rf_band_2g_cck, + rf_band_2g_ofdm, + rf_band_5g_l, + rf_band_5g_m, + rf_band_5g_h, + rf_band_max +}; + +#define rf_gain_num 11 +#define rf_hw_offset_num 10 + +struct rtw_gapk_info { + u32 rf3f_bp[rf_band_max][rf_gain_num][rtw_rf_path_max]; + bool txgapk_bp_done; + s8 offset[rf_gain_num][rtw_rf_path_max]; + s8 fianl_offset[rf_gain_num][rtw_rf_path_max]; + u8 read_txgain; + u8 channel; +}; + + struct rtw_gapk_info gapk; + bool is_bt_iqk_timeout; diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h --- a/drivers/net/wireless/realtek/rtw88/reg.h +++ b/drivers/net/wireless/realtek/rtw88/reg.h +#define reg_pmc_dbg_ctrl1 0xa8 +#define bits_pmc_bt_iqk_sts genmask(22, 21) + +#define bit_ac_queue genmask(7, 0) +#define bit_band genmask(18, 16) +#define bit_gain_ext bit(12) +#define bit_data_l genmask(11, 0) +#define bit_txa_tank bit(4) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c +static void rtw8822c_rfk_handshake(struct rtw_dev *rtwdev, bool is_before_k) +{ + struct rtw_dm_info *dm = &rtwdev->dm_info; + u8 u1b_tmp; + u8 u4b_tmp; + int ret; + + if (is_before_k) { + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[rfk] wifi / bt rfk handshake start!! "); + + if (!dm->is_bt_iqk_timeout) { + ret = read_poll_timeout(rtw_read32_mask, u4b_tmp, + u4b_tmp == 0, 20, 600000, false, + rtwdev, reg_pmc_dbg_ctrl1, + bits_pmc_bt_iqk_sts); + if (ret) { + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[rfk] wait bt iqk finish timeout!! "); + dm->is_bt_iqk_timeout = true; + } + } + + rtw_fw_inform_rfk_status(rtwdev, true); + + ret = read_poll_timeout(rtw_read8_mask, u1b_tmp, + u1b_tmp == 1, 20, 100000, false, + rtwdev, reg_arfr4, bit_wl_rfk); + if (ret) + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[rfk] send wifi rfk start h2c cmd fail!! "); + } else { + rtw_fw_inform_rfk_status(rtwdev, false); + ret = read_poll_timeout(rtw_read8_mask, u1b_tmp, + u1b_tmp == 1, 20, 100000, false, + rtwdev, reg_arfr4, + bit_wl_rfk); + if (ret) + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[rfk] send wifi rfk finish h2c cmd fail!! "); + + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[rfk] wifi / bt rfk handshake finish!! "); + } +} + +static void rtw8822c_rfk_power_save(struct rtw_dev *rtwdev, + bool is_power_save) +{ + u8 path; + + for (path = 0; path < rtwdev->hal.rf_path_num; path++) { + rtw_write32_mask(rtwdev, reg_nctl0, bit_sel_path, path); + rtw_write32_mask(rtwdev, reg_dpd_ctl1_s0, bit_ps_en, + is_power_save ? 0 : 1); + } +} + +static void rtw8822c_txgapk_backup_bb_reg(struct rtw_dev *rtwdev, const u32 reg[], + u32 reg_backup[], u32 reg_num) +{ + u32 i; + + for (i = 0; i < reg_num; i++) { + reg_backup[i] = rtw_read32(rtwdev, reg[i]); + + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] backup bb 0x%x = 0x%x ", + reg[i], reg_backup[i]); + } +} + +static void rtw8822c_txgapk_reload_bb_reg(struct rtw_dev *rtwdev, + const u32 reg[], u32 reg_backup[], + u32 reg_num) +{ + u32 i; + + for (i = 0; i < reg_num; i++) { + rtw_write32(rtwdev, reg[i], reg_backup[i]); + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] reload bb 0x%x = 0x%x ", + reg[i], reg_backup[i]); + } +} + +static bool check_rf_status(struct rtw_dev *rtwdev, u8 status) +{ + u8 reg_rf0_a, reg_rf0_b; + + reg_rf0_a = (u8)rtw_read_rf(rtwdev, rf_path_a, + rf_mode_trxagc, bit_rf_mode); + reg_rf0_b = (u8)rtw_read_rf(rtwdev, rf_path_b, + rf_mode_trxagc, bit_rf_mode); + + if (reg_rf0_a == status || reg_rf0_b == status) + return false; + + return true; +} + +static void rtw8822c_txgapk_tx_pause(struct rtw_dev *rtwdev) +{ + bool status; + int ret; + + rtw_write8(rtwdev, reg_txpause, bit_ac_queue); + rtw_write32_mask(rtwdev, reg_tx_fifo, bit_stop_tx, 0x2); + + ret = read_poll_timeout_atomic(check_rf_status, status, status, + 2, 5000, false, rtwdev, 2); + if (ret) + rtw_warn(rtwdev, "failed to pause tx "); + + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] tx pause!! "); +} + +static void rtw8822c_txgapk_bb_dpk(struct rtw_dev *rtwdev, u8 path) +{ + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s ", __func__); + + rtw_write32_mask(rtwdev, reg_enfn, bit_iqk_dpk_en, 0x1); + rtw_write32_mask(rtwdev, reg_ch_delay_extr2, + bit_iqk_dpk_clock_src, 0x1); + rtw_write32_mask(rtwdev, reg_ch_delay_extr2, + bit_iqk_dpk_reset_src, 0x1); + rtw_write32_mask(rtwdev, reg_ch_delay_extr2, bit_en_ioq_iqk_dpk, 0x1); + rtw_write32_mask(rtwdev, reg_ch_delay_extr2, bit_tst_iqk2set_src, 0x0); + rtw_write32_mask(rtwdev, reg_cca_off, bit_cca_on_by_pw, 0x1ff); + + if (path == rf_path_a) { + rtw_write32_mask(rtwdev, reg_rftxen_gck_a, + bit_rftxen_gck_force_on, 0x1); + rtw_write32_mask(rtwdev, reg_3wire, bit_dis_sharerx_txgat, 0x1); + rtw_write32_mask(rtwdev, reg_dis_share_rx_a, + bit_tx_scale_0db, 0x1); + rtw_write32_mask(rtwdev, reg_3wire, bit_3wire_en, 0x0); + } else if (path == rf_path_b) { + rtw_write32_mask(rtwdev, reg_rftxen_gck_b, + bit_rftxen_gck_force_on, 0x1); + rtw_write32_mask(rtwdev, reg_3wire2, + bit_dis_sharerx_txgat, 0x1); + rtw_write32_mask(rtwdev, reg_dis_share_rx_b, + bit_tx_scale_0db, 0x1); + rtw_write32_mask(rtwdev, reg_3wire2, bit_3wire_en, 0x0); + } + rtw_write32_mask(rtwdev, reg_ccksb, bit_bbmode, 0x2); +} + +static void rtw8822c_txgapk_afe_dpk(struct rtw_dev *rtwdev, u8 path) +{ + u32 reg; + + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s ", __func__); + + if (path == rf_path_a) { + reg = reg_anapar_a; + } else if (path == rf_path_b) { + reg = reg_anapar_b; + } else { + rtw_err(rtwdev, "[txgapk] unknown path %d!! ", path); + return; + } + + rtw_write32_mask(rtwdev, reg_iqk_ctrl, maskdword, maskdword); + rtw_write32_mask(rtwdev, reg, maskdword, 0x700f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x700f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x701f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x702f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x703f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x704f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x705f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x706f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x707f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x708f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x709f0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70af0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70bf0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70cf0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70df0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70ef0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70ff0001); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70ff0001); +} + +static void rtw8822c_txgapk_afe_dpk_restore(struct rtw_dev *rtwdev, u8 path) +{ + u32 reg; + + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s ", __func__); + + if (path == rf_path_a) { + reg = reg_anapar_a; + } else if (path == rf_path_b) { + reg = reg_anapar_b; + } else { + rtw_err(rtwdev, "[txgapk] unknown path %d!! ", path); + return; + } + rtw_write32_mask(rtwdev, reg_iqk_ctrl, maskdword, 0xffa1005e); + rtw_write32_mask(rtwdev, reg, maskdword, 0x700b8041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70144041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70244041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70344041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70444041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x705b8041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70644041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x707b8041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x708b8041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x709b8041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70ab8041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70bb8041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70cb8041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70db8041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70eb8041); + rtw_write32_mask(rtwdev, reg, maskdword, 0x70fb8041); +} + +static void rtw8822c_txgapk_bb_dpk_restore(struct rtw_dev *rtwdev, u8 path) +{ + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s ", __func__); + + rtw_write_rf(rtwdev, path, rf_debug, bit_de_tx_gain, 0x0); + rtw_write_rf(rtwdev, path, rf_dis_bypass_txbb, bit_tia_bypass, 0x0); + rtw_write_rf(rtwdev, path, rf_dis_bypass_txbb, bit_txbb, 0x0); + + rtw_write32_mask(rtwdev, reg_nctl0, bit_sel_path, 0x0); + rtw_write32_mask(rtwdev, reg_iqk_ctl1, bit_tx_cfir, 0x0); + rtw_write32_mask(rtwdev, reg_single_tone_sw, bit_irq_test_mode, 0x0); + rtw_write32_mask(rtwdev, reg_r_config, maskbyte0, 0x00); + rtw_write32_mask(rtwdev, reg_nctl0, bit_sel_path, 0x1); + rtw_write32_mask(rtwdev, reg_iqk_ctl1, bit_tx_cfir, 0x0); + rtw_write32_mask(rtwdev, reg_single_tone_sw, bit_irq_test_mode, 0x0); + rtw_write32_mask(rtwdev, reg_r_config, maskbyte0, 0x00); + rtw_write32_mask(rtwdev, reg_nctl0, bit_sel_path, 0x0); + rtw_write32_mask(rtwdev, reg_cca_off, bit_cca_on_by_pw, 0x0); + + if (path == rf_path_a) { + rtw_write32_mask(rtwdev, reg_rftxen_gck_a, + bit_rftxen_gck_force_on, 0x0); + rtw_write32_mask(rtwdev, reg_3wire, bit_dis_sharerx_txgat, 0x0); + rtw_write32_mask(rtwdev, reg_dis_share_rx_a, + bit_tx_scale_0db, 0x0); + rtw_write32_mask(rtwdev, reg_3wire, bit_3wire_en, 0x3); + } else if (path == rf_path_b) { + rtw_write32_mask(rtwdev, reg_rftxen_gck_b, + bit_rftxen_gck_force_on, 0x0); + rtw_write32_mask(rtwdev, reg_3wire2, + bit_dis_sharerx_txgat, 0x0); + rtw_write32_mask(rtwdev, reg_dis_share_rx_b, + bit_tx_scale_0db, 0x0); + rtw_write32_mask(rtwdev, reg_3wire2, bit_3wire_en, 0x3); + } + + rtw_write32_mask(rtwdev, reg_ccksb, bit_bbmode, 0x0); + rtw_write32_mask(rtwdev, reg_iqk_ctl1, bit_cfir_en, 0x5); +} + +static bool _rtw8822c_txgapk_gain_valid(struct rtw_dev *rtwdev, u32 gain) +{ + if ((field_get(bit_gain_tx_pad_h, gain) >= 0xc) && + (field_get(bit_gain_tx_pad_l, gain) >= 0xe)) + return true; + + return false; +} + +static void _rtw8822c_txgapk_write_gain_bb_table(struct rtw_dev *rtwdev, + u8 band, u8 path) +{ + struct rtw_gapk_info *txgapk = &rtwdev->dm_info.gapk; + u32 v, tmp_3f = 0; + u8 gain, check_txgain; + + rtw_write32_mask(rtwdev, reg_nctl0, bit_sel_path, path); + + switch (band) { + case rf_band_2g_ofdm: + rtw_write32_mask(rtwdev, reg_table_sel, bit_q_gain_sel, 0x0); + break; + case rf_band_5g_l: + rtw_write32_mask(rtwdev, reg_table_sel, bit_q_gain_sel, 0x2); + break; + case rf_band_5g_m: + rtw_write32_mask(rtwdev, reg_table_sel, bit_q_gain_sel, 0x3); + break; + case rf_band_5g_h: + rtw_write32_mask(rtwdev, reg_table_sel, bit_q_gain_sel, 0x4); + break; + default: + break; + } + + rtw_write32_mask(rtwdev, reg_tx_gain_set, maskbyte0, 0x88); + + check_txgain = 0; + for (gain = 0; gain < rf_gain_num; gain++) { + v = txgapk->rf3f_bp[band][gain][path]; + if (_rtw8822c_txgapk_gain_valid(rtwdev, v)) { + if (!check_txgain) { + tmp_3f = txgapk->rf3f_bp[band][gain][path]; + check_txgain = 1; + } + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] tx_gain=0x%03x >= 0xcex ", + txgapk->rf3f_bp[band][gain][path]); + } else { + tmp_3f = txgapk->rf3f_bp[band][gain][path]; + } + + rtw_write32_mask(rtwdev, reg_table_sel, bit_q_gain, tmp_3f); + rtw_write32_mask(rtwdev, reg_table_sel, bit_i_gain, gain); + rtw_write32_mask(rtwdev, reg_table_sel, bit_gain_rst, 0x1); + rtw_write32_mask(rtwdev, reg_table_sel, bit_gain_rst, 0x0); + + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] band=%d 0x1b98[11:0]=0x%03x path=%d ", + band, tmp_3f, path); + } +} + +static void rtw8822c_txgapk_write_gain_bb_table(struct rtw_dev *rtwdev) +{ + u8 path, band; + + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s channel=%d ", + __func__, rtwdev->dm_info.gapk.channel); + + for (band = 0; band < rf_band_max; band++) { + for (path = 0; path < rtwdev->hal.rf_path_num; path++) { + _rtw8822c_txgapk_write_gain_bb_table(rtwdev, + band, path); + } + } +} + +static void rtw8822c_txgapk_read_offset(struct rtw_dev *rtwdev, u8 path) +{ + static const u32 cfg1_1b00[2] = {0x00000d18, 0x00000d2a}; + static const u32 cfg2_1b00[2] = {0x00000d19, 0x00000d2b}; + static const u32 set_pi[2] = {reg_rsv_ctrl, reg_wlrf1}; + static const u32 path_setting[2] = {reg_oritxcode, reg_oritxcode2}; + struct rtw_gapk_info *txgapk = &rtwdev->dm_info.gapk; + u8 channel = txgapk->channel; + u32 val; + int i; + + if (path >= array_size(cfg1_1b00) || + path >= array_size(cfg2_1b00) || + path >= array_size(set_pi) || + path >= array_size(path_setting)) { + rtw_warn(rtwdev, "[txgapk] wrong path %d ", path); + return; + } + + rtw_write32_mask(rtwdev, reg_antmap0, bit_ant_path, path + 1); + rtw_write32_mask(rtwdev, reg_txlgmap, maskdword, 0xe4e40000); + rtw_write32_mask(rtwdev, reg_txantseg, bit_antseg, 0x3); + rtw_write32_mask(rtwdev, path_setting[path], mask20bits, 0x33312); + rtw_write32_mask(rtwdev, path_setting[path], bit_path_en, 0x1); + rtw_write32_mask(rtwdev, set_pi[path], bits_rfc_direct, 0x0); + rtw_write_rf(rtwdev, path, rf_lutdbg, bit_txa_tank, 0x1); + rtw_write_rf(rtwdev, path, rf_idac, bit_tx_mode, 0x820); + rtw_write32_mask(rtwdev, reg_nctl0, bit_sel_path, path); + rtw_write32_mask(rtwdev, reg_iqkstat, maskbyte0, 0x0); + + rtw_write32_mask(rtwdev, reg_tx_tone_idx, maskbyte0, 0x018); + fsleep(1000); + if (channel >= 1 && channel <= 14) + rtw_write32_mask(rtwdev, reg_r_config, maskbyte0, bit_2g_swing); + else + rtw_write32_mask(rtwdev, reg_r_config, maskbyte0, bit_5g_swing); + fsleep(1000); + + rtw_write32_mask(rtwdev, reg_nctl0, maskdword, cfg1_1b00[path]); + rtw_write32_mask(rtwdev, reg_nctl0, maskdword, cfg2_1b00[path]); + + read_poll_timeout(rtw_read32_mask, val, + val == 0x55, 1000, 100000, false, + rtwdev, reg_rpt_cip, bit_rpt_cip_status); + + rtw_write32_mask(rtwdev, set_pi[path], bits_rfc_direct, 0x2); + rtw_write32_mask(rtwdev, reg_nctl0, bit_sel_path, path); + rtw_write32_mask(rtwdev, reg_rxsram_ctl, bit_rpt_en, 0x1); + rtw_write32_mask(rtwdev, reg_rxsram_ctl, bit_rpt_sel, 0x12); + rtw_write32_mask(rtwdev, reg_tx_gain_set, bit_gapk_rpt_idx, 0x3); + val = rtw_read32(rtwdev, reg_stat_rpt); + + txgapk->offset[0][path] = (s8)field_get(bit_gapk_rpt0, val); + txgapk->offset[1][path] = (s8)field_get(bit_gapk_rpt1, val); + txgapk->offset[2][path] = (s8)field_get(bit_gapk_rpt2, val); + txgapk->offset[3][path] = (s8)field_get(bit_gapk_rpt3, val); + txgapk->offset[4][path] = (s8)field_get(bit_gapk_rpt4, val); + txgapk->offset[5][path] = (s8)field_get(bit_gapk_rpt5, val); + txgapk->offset[6][path] = (s8)field_get(bit_gapk_rpt6, val); + txgapk->offset[7][path] = (s8)field_get(bit_gapk_rpt7, val); + + rtw_write32_mask(rtwdev, reg_tx_gain_set, bit_gapk_rpt_idx, 0x4); + val = rtw_read32(rtwdev, reg_stat_rpt); + + txgapk->offset[8][path] = (s8)field_get(bit_gapk_rpt0, val); + txgapk->offset[9][path] = (s8)field_get(bit_gapk_rpt1, val); + + for (i = 0; i < rf_hw_offset_num; i++) + if (txgapk->offset[i][path] & bit(3)) + txgapk->offset[i][path] = txgapk->offset[i][path] | + 0xf0; + for (i = 0; i < rf_hw_offset_num; i++) + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] offset %d %d path=%d ", + txgapk->offset[i][path], i, path); +} + +static void rtw8822c_txgapk_calculate_offset(struct rtw_dev *rtwdev, u8 path) +{ + static const u32 bb_reg[] = {reg_antmap0, reg_txlgmap, reg_txantseg, + reg_oritxcode, reg_oritxcode2}; + struct rtw_gapk_info *txgapk = &rtwdev->dm_info.gapk; + u8 channel = txgapk->channel; + u32 reg_backup[array_size(bb_reg)] = {0}; + + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s channel=%d ", + __func__, channel); + + rtw8822c_txgapk_backup_bb_reg(rtwdev, bb_reg, + reg_backup, array_size(bb_reg)); + + if (channel >= 1 && channel <= 14) { + rtw_write32_mask(rtwdev, + reg_single_tone_sw, bit_irq_test_mode, 0x0); + rtw_write32_mask(rtwdev, reg_nctl0, bit_sel_path, path); + rtw_write32_mask(rtwdev, reg_r_config, bit_iq_switch, 0x3f); + rtw_write32_mask(rtwdev, reg_iqk_ctl1, bit_tx_cfir, 0x0); + rtw_write_rf(rtwdev, path, rf_debug, bit_de_tx_gain, 0x1); + rtw_write_rf(rtwdev, path, rf_mode_trxagc, rfreg_mask, 0x5000f); + rtw_write_rf(rtwdev, path, rf_tx_gain_offset, bit_rf_gain, 0x0); + rtw_write_rf(rtwdev, path, rf_rxg_gain, bit_rxg_gain, 0x1); + rtw_write_rf(rtwdev, path, rf_mode_trxagc, bit_rxagc, 0x0f); + rtw_write_rf(rtwdev, path, rf_debug, bit_de_trxbw, 0x1); + rtw_write_rf(rtwdev, path, rf_bw_trxbb, bit_bw_txbb, 0x1); + rtw_write_rf(rtwdev, path, rf_bw_trxbb, bit_bw_rxbb, 0x0); + rtw_write_rf(rtwdev, path, rf_ext_tia_bw, bit_pw_ext_tia, 0x1); + + rtw_write32_mask(rtwdev, reg_iqkstat, maskbyte0, 0x00); + rtw_write32_mask(rtwdev, reg_table_sel, bit_q_gain_sel, 0x0); + + rtw8822c_txgapk_read_offset(rtwdev, path); + rtw_dbg(rtwdev, rtw_dbg_rfk, "============================= "); + + } else { + rtw_write32_mask(rtwdev, + reg_single_tone_sw, bit_irq_test_mode, 0x0); + rtw_write32_mask(rtwdev, reg_nctl0, bit_sel_path, path); + rtw_write32_mask(rtwdev, reg_r_config, bit_iq_switch, 0x3f); + rtw_write32_mask(rtwdev, reg_iqk_ctl1, bit_tx_cfir, 0x0); + rtw_write_rf(rtwdev, path, rf_debug, bit_de_tx_gain, 0x1); + rtw_write_rf(rtwdev, path, rf_mode_trxagc, rfreg_mask, 0x50011); + rtw_write_rf(rtwdev, path, rf_txa_lb_sw, bit_txa_lb_att, 0x3); + rtw_write_rf(rtwdev, path, rf_txa_lb_sw, bit_lb_att, 0x3); + rtw_write_rf(rtwdev, path, rf_txa_lb_sw, bit_lb_sw, 0x1); + rtw_write_rf(rtwdev, path, + rf_rxa_mix_gain, bit_rxa_mix_gain, 0x2); + rtw_write_rf(rtwdev, path, rf_mode_trxagc, bit_rxagc, 0x12); + rtw_write_rf(rtwdev, path, rf_debug, bit_de_trxbw, 0x1); + rtw_write_rf(rtwdev, path, rf_bw_trxbb, bit_bw_rxbb, 0x0); + rtw_write_rf(rtwdev, path, rf_ext_tia_bw, bit_pw_ext_tia, 0x1); + rtw_write_rf(rtwdev, path, rf_mode_trxagc, bit_rf_mode, 0x5); + + rtw_write32_mask(rtwdev, reg_iqkstat, maskbyte0, 0x0); + + if (channel >= 36 && channel <= 64) + rtw_write32_mask(rtwdev, + reg_table_sel, bit_q_gain_sel, 0x2); + else if (channel >= 100 && channel <= 144) + rtw_write32_mask(rtwdev, + reg_table_sel, bit_q_gain_sel, 0x3); + else if (channel >= 149 && channel <= 177) + rtw_write32_mask(rtwdev, + reg_table_sel, bit_q_gain_sel, 0x4); + + rtw8822c_txgapk_read_offset(rtwdev, path); + rtw_dbg(rtwdev, rtw_dbg_rfk, "============================= "); + } + rtw8822c_txgapk_reload_bb_reg(rtwdev, bb_reg, + reg_backup, array_size(bb_reg)); +} + +static void rtw8822c_txgapk_rf_restore(struct rtw_dev *rtwdev, u8 path) +{ + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s ", __func__); + + if (path >= rtwdev->hal.rf_path_num) + return; + + rtw_write_rf(rtwdev, path, rf_mode_trxagc, bit_rf_mode, 0x3); + rtw_write_rf(rtwdev, path, rf_debug, bit_de_trxbw, 0x0); + rtw_write_rf(rtwdev, path, rf_ext_tia_bw, bit_pw_ext_tia, 0x0); +} + +static u32 rtw8822c_txgapk_cal_gain(struct rtw_dev *rtwdev, u32 gain, s8 offset) +{ + u32 gain_x2, new_gain; + + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s ", __func__); + + if (_rtw8822c_txgapk_gain_valid(rtwdev, gain)) { + new_gain = gain; + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] gain=0x%03x(>=0xcex) offset=%d new_gain=0x%03x ", + gain, offset, new_gain); + return new_gain; + } + + gain_x2 = (gain << 1) + offset; + new_gain = (gain_x2 >> 1) | (gain_x2 & bit(0) ? bit_gain_ext : 0); + + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] gain=0x%x offset=%d new_gain=0x%x ", + gain, offset, new_gain); + + return new_gain; +} + +static void rtw8822c_txgapk_write_tx_gain(struct rtw_dev *rtwdev) +{ + struct rtw_gapk_info *txgapk = &rtwdev->dm_info.gapk; + u32 i, j, tmp = 0x20, tmp_3f, v; + s8 offset_tmp[rf_gain_num] = {0}; + u8 path, band = rf_band_2g_ofdm, channel = txgapk->channel; + + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s ", __func__); + + if (channel >= 1 && channel <= 14) { + tmp = 0x20; + band = rf_band_2g_ofdm; + } else if (channel >= 36 && channel <= 64) { + tmp = 0x200; + band = rf_band_5g_l; + } else if (channel >= 100 && channel <= 144) { + tmp = 0x280; + band = rf_band_5g_m; + } else if (channel >= 149 && channel <= 177) { + tmp = 0x300; + band = rf_band_5g_h; + } else { + rtw_err(rtwdev, "[txgapk] unknown channel %d!! ", channel); + return; + } + + for (path = 0; path < rtwdev->hal.rf_path_num; path++) { + for (i = 0; i < rf_gain_num; i++) { + offset_tmp[i] = 0; + for (j = i; j < rf_gain_num; j++) { + v = txgapk->rf3f_bp[band][j][path]; + if (_rtw8822c_txgapk_gain_valid(rtwdev, v)) + continue; + + offset_tmp[i] += txgapk->offset[j][path]; + txgapk->fianl_offset[i][path] = offset_tmp[i]; + } + + v = txgapk->rf3f_bp[band][i][path]; + if (_rtw8822c_txgapk_gain_valid(rtwdev, v)) + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] tx_gain=0x%03x >= 0xcex ", + txgapk->rf3f_bp[band][i][path]); + else + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] offset %d %d ", + offset_tmp[i], i); + } + + rtw_write_rf(rtwdev, path, rf_lutwe2, rfreg_mask, 0x10000); + for (i = 0; i < rf_gain_num; i++) { + rtw_write_rf(rtwdev, path, + rf_lutwa, rfreg_mask, tmp + i); + + tmp_3f = rtw8822c_txgapk_cal_gain(rtwdev, + txgapk->rf3f_bp[band][i][path], + offset_tmp[i]); + rtw_write_rf(rtwdev, path, rf_lutwd0, + bit_gain_ext | bit_data_l, tmp_3f); + + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] 0x33=0x%05x 0x3f=0x%04x ", + tmp + i, tmp_3f); + } + rtw_write_rf(rtwdev, path, rf_lutwe2, rfreg_mask, 0x0); + } +} + +static void rtw8822c_txgapk_save_all_tx_gain_table(struct rtw_dev *rtwdev) +{ + struct rtw_gapk_info *txgapk = &rtwdev->dm_info.gapk; + static const u32 three_wire[2] = {reg_3wire, reg_3wire2}; + static const u8 ch_num[rf_band_max] = {1, 1, 36, 100, 149}; + static const u8 band_num[rf_band_max] = {0x0, 0x0, 0x1, 0x3, 0x5}; + static const u8 cck[rf_band_max] = {0x1, 0x0, 0x0, 0x0, 0x0}; + u8 path, band, gain, rf0_idx; + u32 rf18, v; + + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s ", __func__); + + if (txgapk->read_txgain == 1) { + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] already read txgapk->read_txgain return!!! "); + rtw8822c_txgapk_write_gain_bb_table(rtwdev); + return; + } + + for (band = 0; band < rf_band_max; band++) { + for (path = 0; path < rtwdev->hal.rf_path_num; path++) { + rf18 = rtw_read_rf(rtwdev, path, rf_cfgch, rfreg_mask); + + rtw_write32_mask(rtwdev, + three_wire[path], bit_3wire_en, 0x0); + rtw_write_rf(rtwdev, path, + rf_cfgch, maskbyte0, ch_num[band]); + rtw_write_rf(rtwdev, path, + rf_cfgch, bit_band, band_num[band]); + rtw_write_rf(rtwdev, path, + rf_bw_trxbb, bit_dbg_cck_cca, cck[band]); + rtw_write_rf(rtwdev, path, + rf_bw_trxbb, bit_tx_cck_ind, cck[band]); + gain = 0; + for (rf0_idx = 1; rf0_idx < 32; rf0_idx += 3) { + rtw_write_rf(rtwdev, path, rf_mode_trxagc, + maskbyte0, rf0_idx); + v = rtw_read_rf(rtwdev, path, + rf_tx_result, rfreg_mask); + txgapk->rf3f_bp[band][gain][path] = v & bit_data_l; + + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] 0x5f=0x%03x band=%d path=%d ", + txgapk->rf3f_bp[band][gain][path], + band, path); + gain++; + } + rtw_write_rf(rtwdev, path, rf_cfgch, rfreg_mask, rf18); + rtw_write32_mask(rtwdev, + three_wire[path], bit_3wire_en, 0x3); + } + } + rtw8822c_txgapk_write_gain_bb_table(rtwdev); + txgapk->read_txgain = 1; +} + +static void rtw8822c_txgapk(struct rtw_dev *rtwdev) +{ + static const u32 bb_reg[2] = {reg_tx_ptcl_ctrl, reg_tx_fifo}; + struct rtw_gapk_info *txgapk = &rtwdev->dm_info.gapk; + u32 bb_reg_backup[2]; + u8 path; + + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] ======>%s ", __func__); + + rtw8822c_txgapk_save_all_tx_gain_table(rtwdev); + + if (txgapk->read_txgain == 0) { + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] txgapk->read_txgain == 0 return!!! "); + return; + } + + if (rtwdev->efuse.power_track_type >= 4 && + rtwdev->efuse.power_track_type <= 7) { + rtw_dbg(rtwdev, rtw_dbg_rfk, + "[txgapk] normal mode in tssi mode. return!!! "); + return; + } + + rtw8822c_txgapk_backup_bb_reg(rtwdev, bb_reg, + bb_reg_backup, array_size(bb_reg)); + rtw8822c_txgapk_tx_pause(rtwdev); + for (path = 0; path < rtwdev->hal.rf_path_num; path++) { + txgapk->channel = rtw_read_rf(rtwdev, path, + rf_cfgch, rfreg_mask) & maskbyte0; + rtw8822c_txgapk_bb_dpk(rtwdev, path); + rtw8822c_txgapk_afe_dpk(rtwdev, path); + rtw8822c_txgapk_calculate_offset(rtwdev, path); + rtw8822c_txgapk_rf_restore(rtwdev, path); + rtw8822c_txgapk_afe_dpk_restore(rtwdev, path); + rtw8822c_txgapk_bb_dpk_restore(rtwdev, path); + } + rtw8822c_txgapk_write_tx_gain(rtwdev); + rtw8822c_txgapk_reload_bb_reg(rtwdev, bb_reg, + bb_reg_backup, array_size(bb_reg)); +} + +static void rtw8822c_do_gapk(struct rtw_dev *rtwdev) +{ + rtw8822c_rfk_handshake(rtwdev, true); + rtw8822c_txgapk(rtwdev); + rtw8822c_rfk_handshake(rtwdev, false); +} + + rtw8822c_rfk_power_save(rtwdev, false); + rtw8822c_do_gapk(rtwdev); + rtw8822c_rfk_power_save(rtwdev, true); diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.h b/drivers/net/wireless/realtek/rtw88/rtw8822c.h --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.h +#define bit_ant_path genmask(1, 0) +#define bit_path_en bit(31) +#define bit_dis_sharerx_txgat bit(27) +#define bit_3wire_en genmask(1, 0) +#define reg_rftxen_gck_a 0x1864 +#define bit_rftxen_gck_force_on bit(31) +#define reg_dis_share_rx_a 0x186c +#define bit_tx_scale_0db bit(7) +#define bit_bbmode genmask(2, 1) +#define bit_sel_path genmask(2, 1) +#define bit_ps_en bit(7) -#define bit_bypass_dpd bit(25) +#define bit_cfir_en genmask(26, 24) +#define bit_bypass_dpd bit(25) + +#define reg_tx_tone_idx 0x1b2c +#define reg_table_sel 0x1b98 +#define bit_i_gain genmask(19, 16) +#define bit_gain_rst bit(15) +#define bit_q_gain_sel genmask(14, 12) +#define bit_q_gain genmask(11, 0) +#define reg_tx_gain_set 0x1b9c +#define bit_gapk_rpt_idx genmask(11, 8) +#define reg_single_tone_sw 0x1bb8 +#define bit_irq_test_mode bit(20) +#define bit_2g_swing 0x2d +#define bit_5g_swing 0x36 +#define bit_rpt_en bit(21) +#define bit_gapk_rpt0 genmask(3, 0) +#define bit_gapk_rpt1 genmask(7, 4) +#define bit_gapk_rpt2 genmask(11, 8) +#define bit_gapk_rpt3 genmask(15, 12) +#define bit_gapk_rpt4 genmask(19, 16) +#define bit_gapk_rpt5 genmask(23, 20) +#define bit_gapk_rpt6 genmask(27, 24) +#define bit_gapk_rpt7 genmask(31, 28) +#define reg_iqk_ctrl 0x1c38 +#define reg_ch_delay_extr2 0x1cd0 +#define bit_tst_iqk2set_src bit(31) +#define bit_en_ioq_iqk_dpk bit(30) +#define bit_iqk_dpk_reset_src bit(29) +#define bit_iqk_dpk_clock_src bit(28) +#define reg_cca_off 0x1d58 +#define bit_cca_on_by_pw genmask(11, 3) + +#define bit_iqk_dpk_en bit(17) +#define bit_antseg genmask(3, 0) +#define reg_tx_fifo 0x1e70 +#define bit_stop_tx genmask(3, 0) +#define bit_rpt_cip_status genmask(7, 0) +#define reg_rftxen_gck_b 0x4164 +#define reg_dis_share_rx_b 0x416c +#define bit_ext_tia_bw bit(1) +#define bit_rf_mode genmask(19, 16) +#define bit_tx_cck_ind bit(16) +#define bit_dbg_cck_cca bit(1) +#define rf_idac 0x58 +#define bit_tx_mode genmask(19, 8) +#define rf_tx_result 0x5f +#define bit_gain_tx_pad_h genmask(11, 8) +#define bit_gain_tx_pad_l genmask(7, 4) +#define bit_pw_ext_tia bit(1) +#define rf_dis_bypass_txbb 0x9e +#define bit_txbb bit(10) +#define bit_tia_bypass bit(5)
|
Networking
|
056b239f867274b573f7da15c43ff8afb523e35c
|
guo feng fan
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: 8822c: debug: allow debugfs to enable/disable txgapk
|
use "cat dm_cap" to show all features; where, prefix +/- means feature is enabled/disabled:
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add gapk
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88 ', '8822c']
|
['h', 'c']
| 3
| 112
| 2
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c --- a/drivers/net/wireless/realtek/rtw88/debug.c +++ b/drivers/net/wireless/realtek/rtw88/debug.c + struct { + u8 bit; + } dm_cap; +static const char * const rtw_dm_cap_strs[] = { + [rtw_dm_cap_na] = "na", + [rtw_dm_cap_txgapk] = "txgapk", +}; + +static ssize_t rtw_debugfs_set_dm_cap(struct file *filp, + const char __user *buffer, + size_t count, loff_t *loff) +{ + struct seq_file *seqpriv = (struct seq_file *)filp->private_data; + struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; + struct rtw_dev *rtwdev = debugfs_priv->rtwdev; + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + int bit; + bool en; + + if (kstrtoint_from_user(buffer, count, 10, &bit)) + return -einval; + + en = bit > 0; + bit = abs(bit); + + if (bit >= rtw_dm_cap_num) { + rtw_warn(rtwdev, "unknown dm cap %d ", bit); + return -einval; + } + + if (en) + dm_info->dm_flags &= ~bit(bit); + else + dm_info->dm_flags |= bit(bit); + + debugfs_priv->dm_cap.bit = bit; + + return count; +} + +static void dump_gapk_status(struct rtw_dev *rtwdev, struct seq_file *m) +{ + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + struct rtw_gapk_info *txgapk = &rtwdev->dm_info.gapk; + int i, path; + u32 val; + + seq_printf(m, " (%2d) %c%s ", rtw_dm_cap_txgapk, + dm_info->dm_flags & bit(rtw_dm_cap_txgapk) ? '-' : '+', + rtw_dm_cap_strs[rtw_dm_cap_txgapk]); + + for (path = 0; path < rtwdev->hal.rf_path_num; path++) { + val = rtw_read_rf(rtwdev, path, rf_gaintx, rfreg_mask); + seq_printf(m, "path %d: 0x%x = 0x%x ", path, rf_gaintx, val); + + for (i = 0; i < rf_hw_offset_num; i++) + seq_printf(m, "[txgapk] offset %d %d ", + txgapk->rf3f_fs[path][i], i); + seq_puts(m, " "); + } +} + +static int rtw_debugfs_get_dm_cap(struct seq_file *m, void *v) +{ + struct rtw_debugfs_priv *debugfs_priv = m->private; + struct rtw_dev *rtwdev = debugfs_priv->rtwdev; + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + int i; + + switch (debugfs_priv->dm_cap.bit) { + case rtw_dm_cap_txgapk: + dump_gapk_status(rtwdev, m); + break; + default: + for (i = 1; i < rtw_dm_cap_num; i++) { + seq_printf(m, "(%2d) %c%s ", i, + dm_info->dm_flags & bit(i) ? '-' : '+', + rtw_dm_cap_strs[i]); + } + break; + } + debugfs_priv->dm_cap.bit = rtw_dm_cap_na; + return 0; +} + +static struct rtw_debugfs_priv rtw_debug_priv_dm_cap = { + .cb_write = rtw_debugfs_set_dm_cap, + .cb_read = rtw_debugfs_get_dm_cap, +}; + + rtw_debugfs_add_rw(dm_cap); diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h + u32 rf3f_fs[rtw_rf_path_max][rf_gain_num]; +enum rtw_dm_cap { + rtw_dm_cap_na, + rtw_dm_cap_txgapk, + rtw_dm_cap_num +}; + + u32 dm_flags; /* enum rtw_dm_cap */ diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c - if (_rtw8822c_txgapk_gain_valid(rtwdev, v)) + if (_rtw8822c_txgapk_gain_valid(rtwdev, v)) { - else + } else { + txgapk->rf3f_fs[path][i] = offset_tmp[i]; + } + if (rtwdev->dm_info.dm_flags & bit(rtw_dm_cap_txgapk)) + return; + + struct rtw_dm_info *dm = &rtwdev->dm_info; + + if (dm->dm_flags & bit(rtw_dm_cap_txgapk)) { + rtw_dbg(rtwdev, rtw_dbg_rfk, "[txgapk] feature disable!!! "); + return; + }
|
Networking
|
3b25bac893534858a8cd0ff79afa929beb8e3b20
|
guo feng fan
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: 8822c: add cfo tracking
|
add cfo tracking, which stands for central frequency offset tracking, to adjust oscillator to align central frequency of connected ap. then, it can yield better performance.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add cfo tracking
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88 ', '8822c']
|
['h', 'c']
| 8
| 224
| 1
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/coex.h b/drivers/net/wireless/realtek/rtw88/coex.h --- a/drivers/net/wireless/realtek/rtw88/coex.h +++ b/drivers/net/wireless/realtek/rtw88/coex.h +static inline bool rtw_coex_disabled(struct rtw_dev *rtwdev) +{ + struct rtw_coex *coex = &rtwdev->coex; + struct rtw_coex_stat *coex_stat = &coex->stat; + + return coex_stat->bt_disabled; +} + diff --git a/drivers/net/wireless/realtek/rtw88/debug.h b/drivers/net/wireless/realtek/rtw88/debug.h --- a/drivers/net/wireless/realtek/rtw88/debug.h +++ b/drivers/net/wireless/realtek/rtw88/debug.h + rtw_dbg_cfo = 0x00002000, diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h + struct ieee80211_hdr *hdr; + void (*cfo_init)(struct rtw_dev *rtwdev); + void (*cfo_track)(struct rtw_dev *rtwdev); +struct rtw_cfo_track { + bool is_adjust; + u8 crystal_cap; + s32 cfo_tail[rtw_rf_path_max]; + s32 cfo_cnt[rtw_rf_path_max]; + u32 packet_count; + u32 packet_count_pre; +}; + + struct rtw_cfo_track cfo_track; diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c --- a/drivers/net/wireless/realtek/rtw88/phy.c +++ b/drivers/net/wireless/realtek/rtw88/phy.c +static void rtw_phy_cfo_init(struct rtw_dev *rtwdev) +{ + struct rtw_chip_info *chip = rtwdev->chip; + + if (chip->ops->cfo_init) + chip->ops->cfo_init(rtwdev); +} + + rtw_phy_cfo_init(rtwdev); +struct rtw_rx_addr_match_data { + struct rtw_dev *rtwdev; + struct ieee80211_hdr *hdr; + struct rtw_rx_pkt_stat *pkt_stat; + u8 *bssid; +}; + +static void rtw_phy_parsing_cfo_iter(void *data, u8 *mac, + struct ieee80211_vif *vif) +{ + struct rtw_rx_addr_match_data *iter_data = data; + struct rtw_dev *rtwdev = iter_data->rtwdev; + struct rtw_rx_pkt_stat *pkt_stat = iter_data->pkt_stat; + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + struct rtw_cfo_track *cfo = &dm_info->cfo_track; + u8 *bssid = iter_data->bssid; + u8 i; + + if (!ether_addr_equal(vif->bss_conf.bssid, bssid)) + return; + + for (i = 0; i < rtwdev->hal.rf_path_num; i++) { + cfo->cfo_tail[i] += pkt_stat->cfo_tail[i]; + cfo->cfo_cnt[i]++; + } + + cfo->packet_count++; +} + +void rtw_phy_parsing_cfo(struct rtw_dev *rtwdev, + struct rtw_rx_pkt_stat *pkt_stat) +{ + struct ieee80211_hdr *hdr = pkt_stat->hdr; + struct rtw_rx_addr_match_data data = {}; + + if (pkt_stat->crc_err || pkt_stat->icv_err || !pkt_stat->phy_status || + ieee80211_is_ctl(hdr->frame_control)) + return; + + data.rtwdev = rtwdev; + data.hdr = hdr; + data.pkt_stat = pkt_stat; + data.bssid = get_hdr_bssid(hdr); + + rtw_iterate_vifs_atomic(rtwdev, rtw_phy_parsing_cfo_iter, &data); +} +export_symbol(rtw_phy_parsing_cfo); + +static void rtw_phy_cfo_track(struct rtw_dev *rtwdev) +{ + struct rtw_chip_info *chip = rtwdev->chip; + + if (chip->ops->cfo_track) + chip->ops->cfo_track(rtwdev); +} + + rtw_phy_cfo_track(rtwdev); diff --git a/drivers/net/wireless/realtek/rtw88/phy.h b/drivers/net/wireless/realtek/rtw88/phy.h --- a/drivers/net/wireless/realtek/rtw88/phy.h +++ b/drivers/net/wireless/realtek/rtw88/phy.h +void rtw_phy_parsing_cfo(struct rtw_dev *rtwdev, + struct rtw_rx_pkt_stat *pkt_stat); diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h --- a/drivers/net/wireless/realtek/rtw88/reg.h +++ b/drivers/net/wireless/realtek/rtw88/reg.h +#define bit_xcap_0 genmask(23, 10) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c +#include "coex.h" - efuse->crystal_cap = map->xtal_k; + efuse->crystal_cap = map->xtal_k & xcap_mask; + rtw_phy_parsing_cfo(rtwdev, pkt_stat); + pkt_stat->hdr = hdr; +#define xcap_extend(val) ({typeof(val) _v = (val); _v | _v << 7; }) +static void rtw8822c_set_crystal_cap_reg(struct rtw_dev *rtwdev, u8 crystal_cap) +{ + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + struct rtw_cfo_track *cfo = &dm_info->cfo_track; + u32 val = 0; + + val = xcap_extend(crystal_cap); + cfo->crystal_cap = crystal_cap; + rtw_write32_mask(rtwdev, reg_anapar_xtal_0, bit_xcap_0, val); +} + +static void rtw8822c_set_crystal_cap(struct rtw_dev *rtwdev, u8 crystal_cap) +{ + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + struct rtw_cfo_track *cfo = &dm_info->cfo_track; + + if (cfo->crystal_cap == crystal_cap) + return; + + rtw8822c_set_crystal_cap_reg(rtwdev, crystal_cap); +} + +static void rtw8822c_cfo_tracking_reset(struct rtw_dev *rtwdev) +{ + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + struct rtw_cfo_track *cfo = &dm_info->cfo_track; + + cfo->is_adjust = true; + + if (cfo->crystal_cap > rtwdev->efuse.crystal_cap) + rtw8822c_set_crystal_cap(rtwdev, cfo->crystal_cap - 1); + else if (cfo->crystal_cap < rtwdev->efuse.crystal_cap) + rtw8822c_set_crystal_cap(rtwdev, cfo->crystal_cap + 1); +} + +static void rtw8822c_cfo_init(struct rtw_dev *rtwdev) +{ + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + struct rtw_cfo_track *cfo = &dm_info->cfo_track; + + cfo->crystal_cap = rtwdev->efuse.crystal_cap; + cfo->is_adjust = true; +} + +#define report_to_khz(val) ({typeof(val) _v = (val); (_v << 1) + (_v >> 1); }) +static s32 rtw8822c_cfo_calc_avg(struct rtw_dev *rtwdev, u8 path_num) +{ + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + struct rtw_cfo_track *cfo = &dm_info->cfo_track; + s32 cfo_avg, cfo_path_sum = 0, cfo_rpt_sum; + u8 i; + + for (i = 0; i < path_num; i++) { + cfo_rpt_sum = report_to_khz(cfo->cfo_tail[i]); + + if (cfo->cfo_cnt[i]) + cfo_avg = cfo_rpt_sum / cfo->cfo_cnt[i]; + else + cfo_avg = 0; + + cfo_path_sum += cfo_avg; + } + + for (i = 0; i < path_num; i++) { + cfo->cfo_tail[i] = 0; + cfo->cfo_cnt[i] = 0; + } + + return cfo_path_sum / path_num; +} + +static void rtw8822c_cfo_need_adjust(struct rtw_dev *rtwdev, s32 cfo_avg) +{ + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + struct rtw_cfo_track *cfo = &dm_info->cfo_track; + + if (!cfo->is_adjust) { + if (abs(cfo_avg) > cfo_trk_enable_th) + cfo->is_adjust = true; + } else { + if (abs(cfo_avg) <= cfo_trk_stop_th) + cfo->is_adjust = false; + } + + if (!rtw_coex_disabled(rtwdev)) { + cfo->is_adjust = false; + rtw8822c_set_crystal_cap(rtwdev, rtwdev->efuse.crystal_cap); + } +} + +static void rtw8822c_cfo_track(struct rtw_dev *rtwdev) +{ + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + struct rtw_cfo_track *cfo = &dm_info->cfo_track; + u8 path_num = rtwdev->hal.rf_path_num; + s8 crystal_cap = cfo->crystal_cap; + s32 cfo_avg = 0; + + if (rtwdev->sta_cnt != 1) { + rtw8822c_cfo_tracking_reset(rtwdev); + return; + } + + if (cfo->packet_count == cfo->packet_count_pre) + return; + + cfo->packet_count_pre = cfo->packet_count; + cfo_avg = rtw8822c_cfo_calc_avg(rtwdev, path_num); + rtw8822c_cfo_need_adjust(rtwdev, cfo_avg); + + if (cfo->is_adjust) { + if (cfo_avg > cfo_trk_adj_th) + crystal_cap++; + else if (cfo_avg < -cfo_trk_adj_th) + crystal_cap--; + + crystal_cap = clamp_t(s8, crystal_cap, 0, xcap_mask); + rtw8822c_set_crystal_cap(rtwdev, (u8)crystal_cap); + } +} + + .cfo_init = rtw8822c_cfo_init, + .cfo_track = rtw8822c_cfo_track, diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.h b/drivers/net/wireless/realtek/rtw88/rtw8822c.h --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.h +#define xcap_mask genmask(6, 0) +#define cfo_trk_enable_th 20 +#define cfo_trk_stop_th 10 +#define cfo_trk_adj_th 10 +
|
Networking
|
fb8517f4fade44fa5e42e29ca4d6e4a7ed50b512
|
po hao huang
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: 8822c: add lc calibration for rtl8822c
|
fix power tracking issue by replacing unnecessary iq calibration with lc calibration. when thermal difference exceeds limitation, let rf circuit adjsut its characteristic to fit in current environment.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add lc calibration for rtl8822c
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88 ', '8822c']
|
['h', 'c']
| 5
| 47
| 2
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h --- a/drivers/net/wireless/realtek/rtw88/main.h +++ b/drivers/net/wireless/realtek/rtw88/main.h + u8 lck_threshold; + u8 thermal_meter_lck; diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c --- a/drivers/net/wireless/realtek/rtw88/phy.c +++ b/drivers/net/wireless/realtek/rtw88/phy.c +bool rtw_phy_pwrtrack_need_lck(struct rtw_dev *rtwdev) +{ + struct rtw_dm_info *dm_info = &rtwdev->dm_info; + u8 delta_lck; + + delta_lck = abs(dm_info->thermal_avg[0] - dm_info->thermal_meter_lck); + if (delta_lck >= rtwdev->chip->lck_threshold) { + dm_info->thermal_meter_lck = dm_info->thermal_avg[0]; + return true; + } + return false; +} +export_symbol(rtw_phy_pwrtrack_need_lck); + diff --git a/drivers/net/wireless/realtek/rtw88/phy.h b/drivers/net/wireless/realtek/rtw88/phy.h --- a/drivers/net/wireless/realtek/rtw88/phy.h +++ b/drivers/net/wireless/realtek/rtw88/phy.h +bool rtw_phy_pwrtrack_need_lck(struct rtw_dev *rtwdev); diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h --- a/drivers/net/wireless/realtek/rtw88/reg.h +++ b/drivers/net/wireless/realtek/rtw88/reg.h +#define rf_syn_pfd 0xb0 +#define rf_syn_ctrl 0xbb +#define rf_syn_aac 0xc9 +#define rf_aac_ctrl 0xca +#define rf_fast_lck 0xcc diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c --- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c + dm_info->thermal_meter_lck = rtwdev->efuse.thermal_meter_k; +static void rtw8822c_do_lck(struct rtw_dev *rtwdev) +{ + u32 val; + + rtw_write_rf(rtwdev, rf_path_a, rf_syn_ctrl, rfreg_mask, 0x80010); + rtw_write_rf(rtwdev, rf_path_a, rf_syn_pfd, rfreg_mask, 0x1f0fa); + fsleep(1); + rtw_write_rf(rtwdev, rf_path_a, rf_aac_ctrl, rfreg_mask, 0x80000); + rtw_write_rf(rtwdev, rf_path_a, rf_syn_aac, rfreg_mask, 0x80001); + read_poll_timeout(rtw_read_rf, val, val != 0x1, 1000, 100000, + true, rtwdev, rf_path_a, rf_aac_ctrl, 0x1000); + rtw_write_rf(rtwdev, rf_path_a, rf_syn_pfd, rfreg_mask, 0x1f0f8); + rtw_write_rf(rtwdev, rf_path_b, rf_syn_ctrl, rfreg_mask, 0x80010); + + rtw_write_rf(rtwdev, rf_path_a, rf_fast_lck, rfreg_mask, 0x0f000); + rtw_write_rf(rtwdev, rf_path_a, rf_fast_lck, rfreg_mask, 0x4f000); + fsleep(1); + rtw_write_rf(rtwdev, rf_path_a, rf_fast_lck, rfreg_mask, 0x0f000); +} + + if (rtw_phy_pwrtrack_need_lck(rtwdev)) + rtw8822c_do_lck(rtwdev); + - if (rtw_phy_pwrtrack_need_iqk(rtwdev)) - rtw8822c_do_iqk(rtwdev); + .lck_threshold = 8,
|
Networking
|
7ae7784ec2a812c07d2ca91a6538ef2470154fb6
|
po hao huang
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: add flush hci support
|
though mac queue flushing has been supported, sometimes data may be waiting on interface from host to chip. if it occurs, there may still be data that flows into mac just after we do flush. to avoid that, we add the hci part of flushing.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add flush hci support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88 ']
|
['h', 'c']
| 3
| 87
| 0
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/hci.h b/drivers/net/wireless/realtek/rtw88/hci.h --- a/drivers/net/wireless/realtek/rtw88/hci.h +++ b/drivers/net/wireless/realtek/rtw88/hci.h + void (*flush_queues)(struct rtw_dev *rtwdev, u32 queues, bool drop); +static inline void rtw_hci_flush_queues(struct rtw_dev *rtwdev, u32 queues, + bool drop) +{ + if (rtwdev->hci.ops->flush_queues) + rtwdev->hci.ops->flush_queues(rtwdev, queues, drop); +} + +static inline void rtw_hci_flush_all_queues(struct rtw_dev *rtwdev, bool drop) +{ + if (rtwdev->hci.ops->flush_queues) + rtwdev->hci.ops->flush_queues(rtwdev, + bit(rtwdev->hw->queues) - 1, + drop); +} + diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c --- a/drivers/net/wireless/realtek/rtw88/mac80211.c +++ b/drivers/net/wireless/realtek/rtw88/mac80211.c + rtw_hci_flush_all_queues(rtwdev, false); + rtw_hci_flush_queues(rtwdev, queues, drop); diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c --- a/drivers/net/wireless/realtek/rtw88/pci.c +++ b/drivers/net/wireless/realtek/rtw88/pci.c +static_assert(array_size(ac_to_hwq) == ieee80211_num_acs); + +static u32 __pci_get_hw_tx_ring_rp(struct rtw_dev *rtwdev, u8 pci_q) +{ + u32 bd_idx_addr = rtw_pci_tx_queue_idx_addr[pci_q]; + u32 bd_idx = rtw_read16(rtwdev, bd_idx_addr + 2); + + return field_get(trx_bd_idx_mask, bd_idx); +} + +static void __pci_flush_queue(struct rtw_dev *rtwdev, u8 pci_q, bool drop) +{ + struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv; + struct rtw_pci_tx_ring *ring = &rtwpci->tx_rings[pci_q]; + u32 cur_rp; + u8 i; + + /* because the time taked by the i/o in __pci_get_hw_tx_ring_rp is a + * bit dynamic, it's hard to define a reasonable fixed total timeout to + * use read_poll_timeout* helper. instead, we can ensure a reasonable + * polling times, so we just use for loop with udelay here. + */ + for (i = 0; i < 30; i++) { + cur_rp = __pci_get_hw_tx_ring_rp(rtwdev, pci_q); + if (cur_rp == ring->r.wp) + return; + + udelay(1); + } + + if (!drop) + rtw_warn(rtwdev, "timed out to flush pci tx ring[%d] ", pci_q); +} + +static void __rtw_pci_flush_queues(struct rtw_dev *rtwdev, u32 pci_queues, + bool drop) +{ + u8 q; + + for (q = 0; q < rtk_max_tx_queue_num; q++) { + /* it may be not necessary to flush bcn and h2c tx queues. */ + if (q == rtw_tx_queue_bcn || q == rtw_tx_queue_h2c) + continue; + + if (pci_queues & bit(q)) + __pci_flush_queue(rtwdev, q, drop); + } +} + +static void rtw_pci_flush_queues(struct rtw_dev *rtwdev, u32 queues, bool drop) +{ + u32 pci_queues = 0; + u8 i; + + /* if all of the hardware queues are requested to flush, + * flush all of the pci queues. + */ + if (queues == bit(rtwdev->hw->queues) - 1) { + pci_queues = bit(rtk_max_tx_queue_num) - 1; + } else { + for (i = 0; i < rtwdev->hw->queues; i++) + if (queues & bit(i)) + pci_queues |= bit(ac_to_hwq[i]); + } + + __rtw_pci_flush_queues(rtwdev, pci_queues, drop); +} + + .flush_queues = rtw_pci_flush_queues,
|
Networking
|
7b33ec8b93c9fa401a8fcd92ebde3129a1beb844
|
zong zhe yang
|
drivers
|
net
|
realtek, rtw88, wireless
|
rtw88: coex: add power off setting
|
clear wl/bt on/off bit in scoreboard register that is used to exchange wl/bt status. since the status is preserved after warm reboot, we must clear it when wl is going to down.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add power off setting
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['rtw88 ', 'coex']
|
['h', 'c']
| 3
| 7
| 0
|
--- diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c --- a/drivers/net/wireless/realtek/rtw88/coex.c +++ b/drivers/net/wireless/realtek/rtw88/coex.c +void rtw_coex_power_off_setting(struct rtw_dev *rtwdev) +{ + rtw_write16(rtwdev, reg_wifi_bt_info, bit_bt_int_en); +} + diff --git a/drivers/net/wireless/realtek/rtw88/coex.h b/drivers/net/wireless/realtek/rtw88/coex.h --- a/drivers/net/wireless/realtek/rtw88/coex.h +++ b/drivers/net/wireless/realtek/rtw88/coex.h +void rtw_coex_power_off_setting(struct rtw_dev *rtwdev); diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c + rtw_coex_power_off_setting(rtwdev);
|
Networking
|
5b492c7dbddaba4a1c1d4e72ec974ee459b4afe7
|
ping ke shih
|
drivers
|
net
|
realtek, rtw88, wireless
|
sfc: ef10: implement ethtool::get_fec_stats
|
report what appears to be the standard block counts: - 30.5.1.1.17 afeccorrectedblocks - 30.5.1.1.18 afecuncorrectableblocks
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
implement ethtool::get_fec_stats
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['sfc', 'ef10']
|
['h', 'c']
| 3
| 30
| 0
|
- 30.5.1.1.17 afeccorrectedblocks - 30.5.1.1.18 afecuncorrectableblocks --- diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c +static void efx_ef10_get_fec_stats(struct efx_nic *efx, + struct ethtool_fec_stats *fec_stats) +{ + declare_bitmap(mask, ef10_stat_count); + struct efx_ef10_nic_data *nic_data = efx->nic_data; + u64 *stats = nic_data->stats; + + efx_ef10_get_stat_mask(efx, mask); + if (test_bit(ef10_stat_fec_corrected_errors, mask)) + fec_stats->corrected_blocks.total = + stats[ef10_stat_fec_corrected_errors]; + if (test_bit(ef10_stat_fec_uncorrected_errors, mask)) + fec_stats->uncorrectable_blocks.total = + stats[ef10_stat_fec_uncorrected_errors]; +} + + .get_fec_stats = efx_ef10_get_fec_stats, diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c +static void efx_ethtool_get_fec_stats(struct net_device *net_dev, + struct ethtool_fec_stats *fec_stats) +{ + struct efx_nic *efx = netdev_priv(net_dev); + + if (efx->type->get_fec_stats) + efx->type->get_fec_stats(efx, fec_stats); +} + + .get_fec_stats = efx_ethtool_get_fec_stats, diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h + * @get_fec_stats: get standard fec statistics. + void (*get_fec_stats)(struct efx_nic *efx, + struct ethtool_fec_stats *fec_stats);
|
Networking
|
cab351be53c263c857563eb56b2bbfe67e8a12a0
|
jakub kicinski
|
drivers
|
net
|
ethernet, sfc
|
net: stmmac: set irq affinity hint for multi msi vectors
|
certain platform likes intel mgbe has independent hardware irq resources for tx and rx dma operation. in preparation to support xdp tx, we add irq affinity hint to group both rx and tx queue of the same queue id to the same cpu.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 13
| 2
|
- irq affinity hint need to set to null before irq is released. --- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c - if (priv->tx_irq[j] > 0) + if (priv->tx_irq[j] > 0) { + irq_set_affinity_hint(priv->tx_irq[j], null); + } - if (priv->rx_irq[j] > 0) + if (priv->rx_irq[j] > 0) { + irq_set_affinity_hint(priv->rx_irq[j], null); + } + cpumask_t cpu_mask; + cpumask_clear(&cpu_mask); + cpumask_set_cpu(i % num_online_cpus(), &cpu_mask); + irq_set_affinity_hint(priv->rx_irq[i], &cpu_mask); + cpumask_clear(&cpu_mask); + cpumask_set_cpu(i % num_online_cpus(), &cpu_mask); + irq_set_affinity_hint(priv->tx_irq[i], &cpu_mask);
|
Networking
|
8deec94c6040bb4a767f6e9456a0a44c7f2e713e
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: make sph enable/disable to be configurable
|
sph functionality splits header and payload according to split mode and offsef fields (splm and splofst). it is beneficials for linux network stack rx processing however it adds a lot of complexity in xdp processing.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 2
| 8
| 5
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h + int sph_cap; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + bool sph_en; - if (priv->sph && priv->hw->rx_csum) { - for (chan = 0; chan < rx_cnt; chan++) - stmmac_enable_sph(priv, priv->ioaddr, 1, chan); - } + sph_en = (priv->hw->rx_csum > 0) && priv->sph; + for (chan = 0; chan < rx_cnt; chan++) + stmmac_enable_sph(priv, priv->ioaddr, sph_en, chan); + - priv->sph = true; + priv->sph_cap = true; + priv->sph = priv->sph_cap;
|
Networking
|
d08d32d101938a26e692c7aee0d452fbeec9d3f3
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: arrange tx tail pointer update to stmmac_flush_tx_descriptors
|
this patch organizes tx tail pointer update into a new function called stmmac_flush_tx_descriptors() so that we can reuse it in stmmac_xmit(), stmmac_tso_xmit() and up-coming xdp implementation.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 26
| 30
|
- fix for warning: unused variable 'desc_size' --- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue) +{ + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; + int desc_size; + + if (likely(priv->extend_desc)) + desc_size = sizeof(struct dma_extended_desc); + else if (tx_q->tbs & stmmac_tbs_avail) + desc_size = sizeof(struct dma_edesc); + else + desc_size = sizeof(struct dma_desc); + + /* the own bit must be the latest setting done when prepare the + * descriptor and then barrier is needed to make sure that + * all is coherent before granting the dma engine. + */ + wmb(); + + tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * desc_size); + stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue); +} + - int desc_size, tmp_pay_len = 0, first_tx; + int tmp_pay_len = 0, first_tx; - /* the own bit must be the latest setting done when prepare the - * descriptor and then barrier is needed to make sure that - * all is coherent before granting the dma engine. - */ - wmb(); - - if (tx_q->tbs & stmmac_tbs_avail) - desc_size = sizeof(struct dma_edesc); - else - desc_size = sizeof(struct dma_desc); - - tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * desc_size); - stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue); + stmmac_flush_tx_descriptors(priv, queue); - int entry, desc_size, first_tx; + int entry, first_tx; - /* the own bit must be the latest setting done when prepare the - * descriptor and then barrier is needed to make sure that - * all is coherent before granting the dma engine. - */ - wmb(); - - if (likely(priv->extend_desc)) - desc_size = sizeof(struct dma_extended_desc); - else if (tx_q->tbs & stmmac_tbs_avail) - desc_size = sizeof(struct dma_edesc); - else - desc_size = sizeof(struct dma_desc); - - tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * desc_size); - stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue); + stmmac_flush_tx_descriptors(priv, queue);
|
Networking
|
d96febedfde250735ac6ed50966ec5453feda355
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add initial xdp support
|
this patch adds the initial xdp support to stmmac driver. it supports xdp_pass, xdp_drop and xdp_aborted actions. upcoming patches will add support for xdp_tx and xdp_redirect.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c', 'makefile']
| 5
| 197
| 27
|
- factor in xdp header and tail adjustment done by xdp program. - fix for "warning: variable 'len' set but not used" reported by lkp. --- diff --git a/drivers/net/ethernet/stmicro/stmmac/makefile b/drivers/net/ethernet/stmicro/stmmac/makefile --- a/drivers/net/ethernet/stmicro/stmmac/makefile +++ b/drivers/net/ethernet/stmicro/stmmac/makefile + stmmac_xdp.o \ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h - struct page *sec_page; + __u32 page_offset; + struct page *sec_page; + + /* xdp bpf program */ + struct bpf_prog *xdp_prog; +int stmmac_open(struct net_device *dev); +int stmmac_release(struct net_device *dev); +static inline bool stmmac_xdp_is_enabled(struct stmmac_priv *priv) +{ + return !!priv->xdp_prog; +} + +static inline unsigned int stmmac_rx_offset(struct stmmac_priv *priv) +{ + if (stmmac_xdp_is_enabled(priv)) + return xdp_packet_headroom; + + return 0; +} + diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +#include <linux/bpf_trace.h> +#include "stmmac_xdp.h" +#define stmmac_xdp_pass 0 +#define stmmac_xdp_consumed bit(0) + + buf->page_offset = stmmac_rx_offset(priv); - buf->addr = page_pool_get_dma_addr(buf->page); + buf->addr = page_pool_get_dma_addr(buf->page) + buf->page_offset; + - buf->addr = page_pool_get_dma_addr(buf->page); + buf->addr = page_pool_get_dma_addr(buf->page) + + buf->page_offset; + bool xdp_prog = stmmac_xdp_is_enabled(priv); - pp_params.flags = pp_flag_dma_map; + pp_params.flags = pp_flag_dma_map | pp_flag_dma_sync_dev; - pp_params.dma_dir = dma_from_device; + pp_params.dma_dir = xdp_prog ? dma_bidirectional : dma_from_device; + pp_params.offset = stmmac_rx_offset(priv); + pp_params.max_len = stmmac_max_rx_buf_size(num_pages); -static int stmmac_open(struct net_device *dev) +int stmmac_open(struct net_device *dev) -static int stmmac_release(struct net_device *dev) +int stmmac_release(struct net_device *dev) - int len, dirty = stmmac_rx_dirty(priv, queue); + int dirty = stmmac_rx_dirty(priv, queue); - len = div_round_up(priv->dma_buf_sz, page_size) * page_size; - - - dma_sync_single_for_device(priv->device, buf->sec_addr, - len, dma_from_device); - buf->addr = page_pool_get_dma_addr(buf->page); - - /* sync whole allocation to device. this will invalidate old - * data. - */ - dma_sync_single_for_device(priv->device, buf->addr, len, - dma_from_device); + buf->addr = page_pool_get_dma_addr(buf->page) + buf->page_offset; +static struct sk_buff *stmmac_xdp_run_prog(struct stmmac_priv *priv, + struct xdp_buff *xdp) +{ + struct bpf_prog *prog; + int res; + u32 act; + + rcu_read_lock(); + + prog = read_once(priv->xdp_prog); + if (!prog) { + res = stmmac_xdp_pass; + goto unlock; + } + + act = bpf_prog_run_xdp(prog, xdp); + switch (act) { + case xdp_pass: + res = stmmac_xdp_pass; + break; + default: + bpf_warn_invalid_xdp_action(act); + fallthrough; + case xdp_aborted: + trace_xdp_exception(priv->dev, prog, act); + fallthrough; + case xdp_drop: + res = stmmac_xdp_consumed; + break; + } + +unlock: + rcu_read_unlock(); + return err_ptr(-res); +} + + enum dma_data_direction dma_dir; + struct xdp_buff xdp; + int buf_sz; + + dma_dir = page_pool_get_dma_dir(rx_q->page_pool); + buf_sz = div_round_up(priv->dma_buf_sz, page_size) * page_size; + dma_sync_single_for_cpu(priv->device, buf->addr, + buf1_len, dma_dir); + + xdp.data = page_address(buf->page) + buf->page_offset; + xdp.data_end = xdp.data + buf1_len; + xdp.data_hard_start = page_address(buf->page); + xdp_set_data_meta_invalid(&xdp); + xdp.frame_sz = buf_sz; + + skb = stmmac_xdp_run_prog(priv, &xdp); + + /* for not xdp_pass verdict */ + if (is_err(skb)) { + unsigned int xdp_res = -ptr_err(skb); + + if (xdp_res & stmmac_xdp_consumed) { + page_pool_recycle_direct(rx_q->page_pool, + buf->page); + buf->page = null; + priv->dev->stats.rx_dropped++; + + /* clear skb as it was set as + * status by xdp program. + */ + skb = null; + + if (unlikely((status & rx_not_ls))) + goto read_again; + + count++; + continue; + } + } + } + + if (!skb) { + /* xdp program may expand or reduce tail */ + buf1_len = xdp.data_end - xdp.data; + - dma_sync_single_for_cpu(priv->device, buf->addr, - buf1_len, dma_from_device); - skb_copy_to_linear_data(skb, page_address(buf->page), - buf1_len); + /* xdp program may adjust header */ + skb_copy_to_linear_data(skb, xdp.data, buf1_len); - buf1_len, dma_from_device); + buf1_len, dma_dir); - buf->page, 0, buf1_len, + buf->page, buf->page_offset, buf1_len, - buf2_len, dma_from_device); + buf2_len, dma_dir); + if (stmmac_xdp_is_enabled(priv) && new_mtu > eth_data_len) { + netdev_dbg(priv->dev, "jumbo frames not supported for xdp "); + return -einval; + } + + +static int stmmac_bpf(struct net_device *dev, struct netdev_bpf *bpf) +{ + struct stmmac_priv *priv = netdev_priv(dev); + + switch (bpf->command) { + case xdp_setup_prog: + return stmmac_xdp_set_prog(priv, bpf->prog, bpf->extack); + default: + return -eopnotsupp; + } +} + + .ndo_bpf = stmmac_bpf, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c +// spdx-license-identifier: gpl-2.0 +/* copyright (c) 2021, intel corporation. */ + +#include "stmmac.h" +#include "stmmac_xdp.h" + +int stmmac_xdp_set_prog(struct stmmac_priv *priv, struct bpf_prog *prog, + struct netlink_ext_ack *extack) +{ + struct net_device *dev = priv->dev; + struct bpf_prog *old_prog; + bool need_update; + bool if_running; + + if_running = netif_running(dev); + + if (prog && dev->mtu > eth_data_len) { + /* for now, the driver doesn't support xdp functionality with + * jumbo frames so we return error. + */ + nl_set_err_msg_mod(extack, "jumbo frames not supported"); + return -eopnotsupp; + } + + need_update = !!priv->xdp_prog != !!prog; + if (if_running && need_update) + stmmac_release(dev); + + old_prog = xchg(&priv->xdp_prog, prog); + if (old_prog) + bpf_prog_put(old_prog); + + /* disable rx sph for xdp operation */ + priv->sph = priv->sph_cap && !stmmac_xdp_is_enabled(priv); + + if (if_running && need_update) + stmmac_open(dev); + + return 0; +} diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.h --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.h +/* spdx-license-identifier: gpl-2.0 */ +/* copyright (c) 2021, intel corporation. */ + +#ifndef _stmmac_xdp_h_ +#define _stmmac_xdp_h_ + +#define stmmac_max_rx_buf_size(num) (((num) * page_size) - xdp_packet_headroom) + +int stmmac_xdp_set_prog(struct stmmac_priv *priv, struct bpf_prog *prog, + struct netlink_ext_ack *extack); + +#endif /* _stmmac_xdp_h_ */
|
Networking
|
5fabb01207a2d3439a6abe1d08640de9c942945f
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add support for xdp_tx action
|
this patch adds support for xdp_tx action which enables xdp program to transmit back received frames.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 2
| 232
| 18
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h +enum stmmac_txbuf_type { + stmmac_txbuf_t_skb, + stmmac_txbuf_t_xdp_tx, +}; + + enum stmmac_txbuf_type buf_type; - struct sk_buff **tx_skbuff; + union { + struct sk_buff **tx_skbuff; + struct xdp_frame **xdpf; + }; + struct xdp_rxq_info xdp_rxq; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +#define stmmac_xdp_tx bit(1) - if (tx_q->tx_skbuff_dma[i].buf) { + if (tx_q->tx_skbuff_dma[i].buf && + tx_q->tx_skbuff_dma[i].buf_type != stmmac_txbuf_t_xdp_tx) { - if (tx_q->tx_skbuff[i]) { + if (tx_q->xdpf[i] && + tx_q->tx_skbuff_dma[i].buf_type == stmmac_txbuf_t_xdp_tx) { + xdp_return_frame(tx_q->xdpf[i]); + tx_q->xdpf[i] = null; + } + + if (tx_q->tx_skbuff[i] && + tx_q->tx_skbuff_dma[i].buf_type == stmmac_txbuf_t_skb) { - tx_q->tx_skbuff_dma[i].buf = 0; - tx_q->tx_skbuff_dma[i].map_as_page = false; + + tx_q->tx_skbuff_dma[i].buf = 0; + tx_q->tx_skbuff_dma[i].map_as_page = false; + int ret; + warn_on(xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq, + mem_type_page_pool, + rx_q->page_pool)); + + netdev_info(priv->dev, + "register mem_type_page_pool rxq-%d ", + rx_q->queue_index); + + if (xdp_rxq_info_is_reg(&rx_q->xdp_rxq)) + xdp_rxq_info_unreg(&rx_q->xdp_rxq); + + struct stmmac_channel *ch = &priv->channel[queue]; + int ret; + + ret = xdp_rxq_info_reg(&rx_q->xdp_rxq, priv->dev, + rx_q->queue_index, + ch->rx_napi.napi_id); + if (ret) { + netdev_err(priv->dev, "failed to register xdp rxq info "); + goto err_dma; + } - /* release the dma rx socket buffers */ - free_dma_rx_desc_resources(priv); - + + /* release the dma rx socket buffers later + * to ensure all pending xdp_tx buffers are returned. + */ + free_dma_rx_desc_resources(priv); - struct sk_buff *skb = tx_q->tx_skbuff[entry]; + struct xdp_frame *xdpf; + struct sk_buff *skb; + if (tx_q->tx_skbuff_dma[entry].buf_type == stmmac_txbuf_t_xdp_tx) { + xdpf = tx_q->xdpf[entry]; + skb = null; + } else if (tx_q->tx_skbuff_dma[entry].buf_type == stmmac_txbuf_t_skb) { + xdpf = null; + skb = tx_q->tx_skbuff[entry]; + } else { + xdpf = null; + skb = null; + } + - stmmac_get_tx_hwtstamp(priv, p, skb); + if (skb) + stmmac_get_tx_hwtstamp(priv, p, skb); - if (likely(tx_q->tx_skbuff_dma[entry].buf)) { + if (likely(tx_q->tx_skbuff_dma[entry].buf && + tx_q->tx_skbuff_dma[entry].buf_type != stmmac_txbuf_t_xdp_tx)) { - if (likely(skb != null)) { - pkts_compl++; - bytes_compl += skb->len; - dev_consume_skb_any(skb); - tx_q->tx_skbuff[entry] = null; + if (xdpf && + tx_q->tx_skbuff_dma[entry].buf_type == stmmac_txbuf_t_xdp_tx) { + xdp_return_frame_rx_napi(xdpf); + tx_q->xdpf[entry] = null; + } + + if (tx_q->tx_skbuff_dma[entry].buf_type == stmmac_txbuf_t_skb) { + if (likely(skb)) { + pkts_compl++; + bytes_compl += skb->len; + dev_consume_skb_any(skb); + tx_q->tx_skbuff[entry] = null; + } + tx_q->tx_skbuff_dma[first_entry].map_as_page = false; + tx_q->tx_skbuff_dma[first_entry].buf_type = stmmac_txbuf_t_skb; + tx_q->tx_skbuff_dma[tx_q->cur_tx].buf_type = stmmac_txbuf_t_skb; + tx_q->tx_skbuff_dma[tx_q->cur_tx].buf_type = stmmac_txbuf_t_skb; + tx_q->tx_skbuff_dma[entry].buf_type = stmmac_txbuf_t_skb; + tx_q->tx_skbuff_dma[entry].buf_type = stmmac_txbuf_t_skb; + tx_q->tx_skbuff_dma[first_entry].buf_type = stmmac_txbuf_t_skb; + tx_q->tx_skbuff_dma[first_entry].map_as_page = false; +static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue, + struct xdp_frame *xdpf) +{ + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; + struct page *page = virt_to_page(xdpf->data); + unsigned int entry = tx_q->cur_tx; + struct dma_desc *tx_desc; + dma_addr_t dma_addr; + bool set_ic; + + if (stmmac_tx_avail(priv, queue) < stmmac_tx_thresh(priv)) + return stmmac_xdp_consumed; + + if (likely(priv->extend_desc)) + tx_desc = (struct dma_desc *)(tx_q->dma_etx + entry); + else if (tx_q->tbs & stmmac_tbs_avail) + tx_desc = &tx_q->dma_entx[entry].basic; + else + tx_desc = tx_q->dma_tx + entry; + + dma_addr = page_pool_get_dma_addr(page) + sizeof(*xdpf) + + xdpf->headroom; + dma_sync_single_for_device(priv->device, dma_addr, + xdpf->len, dma_bidirectional); + + tx_q->tx_skbuff_dma[entry].buf_type = stmmac_txbuf_t_xdp_tx; + + tx_q->tx_skbuff_dma[entry].buf = dma_addr; + tx_q->tx_skbuff_dma[entry].map_as_page = false; + tx_q->tx_skbuff_dma[entry].len = xdpf->len; + tx_q->tx_skbuff_dma[entry].last_segment = true; + tx_q->tx_skbuff_dma[entry].is_jumbo = false; + + tx_q->xdpf[entry] = xdpf; + + stmmac_set_desc_addr(priv, tx_desc, dma_addr); + + stmmac_prepare_tx_desc(priv, tx_desc, 1, xdpf->len, + true, priv->mode, true, true, + xdpf->len); + + tx_q->tx_count_frames++; + + if (tx_q->tx_count_frames % priv->tx_coal_frames[queue] == 0) + set_ic = true; + else + set_ic = false; + + if (set_ic) { + tx_q->tx_count_frames = 0; + stmmac_set_tx_ic(priv, tx_desc); + priv->xstats.tx_set_ic_bit++; + } + + stmmac_enable_dma_transmission(priv, priv->ioaddr); + + entry = stmmac_get_entry(entry, priv->dma_tx_size); + tx_q->cur_tx = entry; + + return stmmac_xdp_tx; +} + +static int stmmac_xdp_get_tx_queue(struct stmmac_priv *priv, + int cpu) +{ + int index = cpu; + + if (unlikely(index < 0)) + index = 0; + + while (index >= priv->plat->tx_queues_to_use) + index -= priv->plat->tx_queues_to_use; + + return index; +} + +static int stmmac_xdp_xmit_back(struct stmmac_priv *priv, + struct xdp_buff *xdp) +{ + struct xdp_frame *xdpf = xdp_convert_buff_to_frame(xdp); + int cpu = smp_processor_id(); + struct netdev_queue *nq; + int queue; + int res; + + if (unlikely(!xdpf)) + return stmmac_xdp_consumed; + + queue = stmmac_xdp_get_tx_queue(priv, cpu); + nq = netdev_get_tx_queue(priv->dev, queue); + + __netif_tx_lock(nq, cpu); + /* avoids tx time-out as we are sharing with slow path */ + nq->trans_start = jiffies; + + res = stmmac_xdp_xmit_xdpf(priv, queue, xdpf); + if (res == stmmac_xdp_tx) + stmmac_flush_tx_descriptors(priv, queue); + + __netif_tx_unlock(nq); + + return res; +} + + case xdp_tx: + res = stmmac_xdp_xmit_back(priv, xdp); + break; +static void stmmac_finalize_xdp_rx(struct stmmac_priv *priv, + int xdp_status) +{ + int cpu = smp_processor_id(); + int queue; + + queue = stmmac_xdp_get_tx_queue(priv, cpu); + + if (xdp_status & stmmac_xdp_tx) + stmmac_tx_timer_arm(priv, queue); +} + + int xdp_status = 0; + unsigned int pre_len, sync_len; + + xdp.rxq = &rx_q->xdp_rxq; + pre_len = xdp.data_end - xdp.data_hard_start - + buf->page_offset; + /* due xdp_adjust_tail: dma sync for_device + * cover max len cpu touch + */ + sync_len = xdp.data_end - xdp.data_hard_start - + buf->page_offset; + sync_len = max(sync_len, pre_len); - page_pool_recycle_direct(rx_q->page_pool, - buf->page); + page_pool_put_page(rx_q->page_pool, + virt_to_head_page(xdp.data), + sync_len, true); + } else if (xdp_res & stmmac_xdp_tx) { + xdp_status |= xdp_res; + buf->page = null; + skb = null; + count++; + continue; + stmmac_finalize_xdp_rx(priv, xdp_status); +
|
Networking
|
be8b38a722e68ffa069b7dfa887369c33d6ea886
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add support for xdp_redirect action
|
this patch adds the support of xdp_redirect to another remote cpu for further action. it also implements ndo_xdp_xmit ops, enabling the driver to transmit packets forwarded to it by xdp program running on another interface.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 2
| 84
| 11
|
+ drop testing. it also been tested with "xdp_redirect" sample app --- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h + stmmac_txbuf_t_xdp_ndo, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +#define stmmac_xdp_redirect bit(2) - tx_q->tx_skbuff_dma[i].buf_type == stmmac_txbuf_t_xdp_tx) { + (tx_q->tx_skbuff_dma[i].buf_type == stmmac_txbuf_t_xdp_tx || + tx_q->tx_skbuff_dma[i].buf_type == stmmac_txbuf_t_xdp_ndo)) { - if (tx_q->tx_skbuff_dma[entry].buf_type == stmmac_txbuf_t_xdp_tx) { + if (tx_q->tx_skbuff_dma[entry].buf_type == stmmac_txbuf_t_xdp_tx || + tx_q->tx_skbuff_dma[entry].buf_type == stmmac_txbuf_t_xdp_ndo) { + if (xdpf && + tx_q->tx_skbuff_dma[entry].buf_type == stmmac_txbuf_t_xdp_ndo) { + xdp_return_frame(xdpf); + tx_q->xdpf[entry] = null; + } + - struct xdp_frame *xdpf) + struct xdp_frame *xdpf, bool dma_map) - struct page *page = virt_to_page(xdpf->data); - dma_addr = page_pool_get_dma_addr(page) + sizeof(*xdpf) + - xdpf->headroom; - dma_sync_single_for_device(priv->device, dma_addr, - xdpf->len, dma_bidirectional); + if (dma_map) { + dma_addr = dma_map_single(priv->device, xdpf->data, + xdpf->len, dma_to_device); + if (dma_mapping_error(priv->device, dma_addr)) + return stmmac_xdp_consumed; + + tx_q->tx_skbuff_dma[entry].buf_type = stmmac_txbuf_t_xdp_ndo; + } else { + struct page *page = virt_to_page(xdpf->data); + + dma_addr = page_pool_get_dma_addr(page) + sizeof(*xdpf) + + xdpf->headroom; + dma_sync_single_for_device(priv->device, dma_addr, + xdpf->len, dma_bidirectional); - tx_q->tx_skbuff_dma[entry].buf_type = stmmac_txbuf_t_xdp_tx; + tx_q->tx_skbuff_dma[entry].buf_type = stmmac_txbuf_t_xdp_tx; + } - res = stmmac_xdp_xmit_xdpf(priv, queue, xdpf); + res = stmmac_xdp_xmit_xdpf(priv, queue, xdpf, false); + case xdp_redirect: + if (xdp_do_redirect(priv->dev, xdp, prog) < 0) + res = stmmac_xdp_consumed; + else + res = stmmac_xdp_redirect; + break; + + if (xdp_status & stmmac_xdp_redirect) + xdp_do_flush(); - } else if (xdp_res & stmmac_xdp_tx) { + } else if (xdp_res & (stmmac_xdp_tx | + stmmac_xdp_redirect)) { +static int stmmac_xdp_xmit(struct net_device *dev, int num_frames, + struct xdp_frame **frames, u32 flags) +{ + struct stmmac_priv *priv = netdev_priv(dev); + int cpu = smp_processor_id(); + struct netdev_queue *nq; + int i, nxmit = 0; + int queue; + + if (unlikely(test_bit(stmmac_down, &priv->state))) + return -enetdown; + + if (unlikely(flags & ~xdp_xmit_flags_mask)) + return -einval; + + queue = stmmac_xdp_get_tx_queue(priv, cpu); + nq = netdev_get_tx_queue(priv->dev, queue); + + __netif_tx_lock(nq, cpu); + /* avoids tx time-out as we are sharing with slow path */ + nq->trans_start = jiffies; + + for (i = 0; i < num_frames; i++) { + int res; + + res = stmmac_xdp_xmit_xdpf(priv, queue, frames[i], true); + if (res == stmmac_xdp_consumed) + break; + + nxmit++; + } + + if (flags & xdp_xmit_flush) { + stmmac_flush_tx_descriptors(priv, queue); + stmmac_tx_timer_arm(priv, queue); + } + + __netif_tx_unlock(nq); + + return nxmit; +} + + .ndo_xdp_xmit = stmmac_xdp_xmit,
|
Networking
|
8b278a5b69a2298055b99895ddc5b5f4ab430df5
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: est interrupts handling and error reporting
|
enabled est related interrupts as below: 1) constant gate control error (cgce) 2) head-of-line blocking due to scheduling (hlbs) 3) head-of-line blocking due to frame size (hlbf). 4) base time register error (btre) 5) switch to s/w owned list complete (swlc)
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
est interrupts and ethtool
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 4
| 114
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c + + /* configure est interrupt */ + if (cfg->enable) + ctrl = (iecgce | iehs | iehf | iebe | iecc); + else + ctrl = 0; + + writel(ctrl, ioaddr + mtl_est_int_en); + +void dwmac5_est_irq_status(void __iomem *ioaddr, struct net_device *dev, + u32 txqcnt) +{ + u32 status, value, feqn, hbfq, hbfs, btrl; + u32 txqcnt_mask = (1 << txqcnt) - 1; + + status = readl(ioaddr + mtl_est_status); + + value = (cgce | hlbs | hlbf | btre | swlc); + + /* return if there is no error */ + if (!(status & value)) + return; + + if (status & cgce) { + /* clear interrupt */ + writel(cgce, ioaddr + mtl_est_status); + } + + if (status & hlbs) { + value = readl(ioaddr + mtl_est_sch_err); + value &= txqcnt_mask; + + /* clear interrupt */ + writel(value, ioaddr + mtl_est_sch_err); + + /* collecting info to shows all the queues that has hlbs + * issue. the only way to clear this is to clear the + * statistic + */ + if (net_ratelimit()) + netdev_err(dev, "est: hlb(sched) queue 0x%x ", value); + } + + if (status & hlbf) { + value = readl(ioaddr + mtl_est_frm_sz_err); + feqn = value & txqcnt_mask; + + value = readl(ioaddr + mtl_est_frm_sz_cap); + hbfq = (value & sz_cap_hbfq_mask(txqcnt)) >> sz_cap_hbfq_shift; + hbfs = value & sz_cap_hbfs_mask; + + /* clear interrupt */ + writel(feqn, ioaddr + mtl_est_frm_sz_err); + + if (net_ratelimit()) + netdev_err(dev, "est: hlb(size) queue %u size %u ", + hbfq, hbfs); + } + + if (status & btre) { + btrl = (status & btrl) >> btrl_shift; + + if (net_ratelimit()) + netdev_info(dev, "est: btr error loop count %u ", + btrl); + + writel(btre, ioaddr + mtl_est_status); + } + + if (status & swlc) { + writel(swlc, ioaddr + mtl_est_status); + netdev_info(dev, "est: swol has been switched "); + } +} + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h + +#define mtl_est_status 0x00000c58 +#define btrl genmask(11, 8) +#define btrl_shift 8 +#define btrl_max (0xf << btrl_shift) +#define swol bit(7) +#define swol_shift 7 +#define cgce bit(4) +#define hlbs bit(3) +#define hlbf bit(2) +#define btre bit(1) +#define swlc bit(0) + +#define mtl_est_sch_err 0x00000c60 +#define mtl_est_frm_sz_err 0x00000c64 +#define mtl_est_frm_sz_cap 0x00000c68 +#define sz_cap_hbfs_mask genmask(14, 0) +#define sz_cap_hbfq_shift 16 +#define sz_cap_hbfq_mask(_val) ({ typeof(_val) (val) = (_val); \ + ((val) > 4 ? genmask(18, 16) : \ + (val) > 2 ? genmask(17, 16) : \ + bit(16)); }) + +#define mtl_est_int_en 0x00000c70 +#define iecgce cgce +#define iehs hlbs +#define iehf hlbf +#define iebe btre +#define iecc swlc + +void dwmac5_est_irq_status(void __iomem *ioaddr, struct net_device *dev, + u32 txqcnt); diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h + void (*est_irq_status)(void __iomem *ioaddr, struct net_device *dev, + u32 txqcnt); +#define stmmac_est_irq_status(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, est_irq_status, __args) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + if (priv->dma_cap.estsel) + stmmac_est_irq_status(priv, priv->ioaddr, priv->dev, tx_cnt); +
|
Networking
|
e49aa315cb01828e7aec0710f3b954e80ba70dd8
|
voon weifeng
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add est errors into ethtool statistic
|
below est errors are added into ethtool statistic: 1) constant gate control error (cgce): the counter "mtl_est_cgce" increases everytime cgce interrupt is triggered.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
est interrupts and ethtool
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 6
| 28
| 4
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h + /* est */ + unsigned long mtl_est_cgce; + unsigned long mtl_est_hlbs; + unsigned long mtl_est_hlbf; + unsigned long mtl_est_btre; + unsigned long mtl_est_btrlm; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c - u32 txqcnt) + struct stmmac_extra_stats *x, u32 txqcnt) + + x->mtl_est_cgce++; + x->mtl_est_hlbs++; + + x->mtl_est_hlbf++; + + if ((status & btrl) == btrl_max) + x->mtl_est_btrlm++; + else + x->mtl_est_btre++; + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h - u32 txqcnt); + struct stmmac_extra_stats *x, u32 txqcnt); diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h - u32 txqcnt); + struct stmmac_extra_stats *x, u32 txqcnt); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c + /* est */ + stmmac_stat(mtl_est_cgce), + stmmac_stat(mtl_est_hlbs), + stmmac_stat(mtl_est_hlbf), + stmmac_stat(mtl_est_btre), + stmmac_stat(mtl_est_btrlm), diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c - stmmac_est_irq_status(priv, priv->ioaddr, priv->dev, tx_cnt); + stmmac_est_irq_status(priv, priv->ioaddr, priv->dev, + &priv->xstats, tx_cnt);
|
Networking
|
9f298959191b0a3a8451ad308a68a9d697ea6819
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add hw descriptor prefetch setting for dwmac core 5.20 onwards
|
dwmac core 5.20 onwards supports hw descriptor prefetching. additionally, it also depends on platform specific rtl configuration. this capability could be enabled by setting dma_mode bit-19 (dche).
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
enable dwmac hw descriptor prefetch
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 5
| 16
| 2
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h +#define dwmac_core_5_20 0x52 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c + value = readl(ioaddr + dma_bus_mode); + - value = readl(ioaddr + dma_bus_mode); - writel(value, ioaddr + dma_bus_mode); + + if (dma_cfg->dche) + value |= dma_bus_mode_dche; + + writel(value, ioaddr + dma_bus_mode); + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h +#define dma_bus_mode_dche bit(19) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + /* only dwmac core version 5.20 onwards supports hw descriptor prefetch. + */ + if (priv->synopsys_id < dwmac_core_5_20) + priv->plat->dma_cfg->dche = false; + diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h + bool dche;
|
Networking
|
96874c619c200bc704ae2d8e34a3746350922135
|
mohammad athari bin ismail
|
include
|
linux
|
ethernet, stmicro, stmmac
|
stmmac: intel: enable hw descriptor prefetch by default
|
enable hw descriptor prefetch by default by setting plat->dma_cfg->dche = true in intel_mgbe_common_data(). need to be noted that this capability only be supported in dwmac core version 5.20 onwards. in stmmac, there is a checking to check the core version. if the core version is below 5.20, this capability wouldn't be configured.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
enable dwmac hw descriptor prefetch
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 1
| 0
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c + plat->dma_cfg->dche = true;
|
Networking
|
676b7ec67d79ae77c6634e75344d82fc4b885e65
|
mohammad athari bin ismail
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: rearrange rx buffer allocation and free functions
|
this patch restructures the per rx queue buffer allocation from page_pool to stmmac_alloc_rx_buffers().
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp zc support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 47
| 37
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +/** + * dma_free_rx_skbufs - free rx dma buffers + * @priv: private structure + * @queue: rx queue index + */ +static void dma_free_rx_skbufs(struct stmmac_priv *priv, u32 queue) +{ + int i; + + for (i = 0; i < priv->dma_rx_size; i++) + stmmac_free_rx_buffer(priv, queue, i); +} + +static int stmmac_alloc_rx_buffers(struct stmmac_priv *priv, u32 queue, + gfp_t flags) +{ + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + int i; + + for (i = 0; i < priv->dma_rx_size; i++) { + struct dma_desc *p; + int ret; + + if (priv->extend_desc) + p = &((rx_q->dma_erx + i)->basic); + else + p = rx_q->dma_rx + i; + + ret = stmmac_init_rx_buffers(priv, p, i, flags, + queue); + if (ret) + return ret; + } + + return 0; +} + - do { - while (--i >= 0) - stmmac_free_rx_buffer(priv, queue, i); + while (queue >= 0) { + dma_free_rx_skbufs(priv, queue); - i = priv->dma_rx_size; - } while (queue-- > 0); + queue--; + } - int i; - int ret; + - for (i = 0; i < priv->dma_rx_size; i++) { - struct dma_desc *p; - - if (priv->extend_desc) - p = &((rx_q->dma_erx + i)->basic); - else - p = rx_q->dma_rx + i; - - ret = stmmac_init_rx_buffers(priv, p, i, flags, - queue); - if (ret) - goto err_init_rx_buffers; - } + ret = stmmac_alloc_rx_buffers(priv, queue, flags); + if (ret < 0) + goto err_init_rx_buffers; - rx_q->dirty_rx = (unsigned int)(i - priv->dma_rx_size); + rx_q->dirty_rx = 0; - while (--i >= 0) - stmmac_free_rx_buffer(priv, queue, i); + dma_free_rx_skbufs(priv, queue); - i = priv->dma_rx_size; -/** - * dma_free_rx_skbufs - free rx dma buffers - * @priv: private structure - * @queue: rx queue index - */ -static void dma_free_rx_skbufs(struct stmmac_priv *priv, u32 queue) -{ - int i; - - for (i = 0; i < priv->dma_rx_size; i++) - stmmac_free_rx_buffer(priv, queue, i); -} -
|
Networking
|
4298255f26fa91c698048e5cc79e371f3bfaf1da
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: introduce dma_recycle_rx_skbufs for stmmac_reinit_rx_buffers
|
rearrange rx buffer page_pool recycling logics into dma_recycle_rx_skbufs, so that we prepare stmmac_reinit_rx_buffers() for xsk pool expansion.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp zc support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 27
| 17
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +/** + * dma_recycle_rx_skbufs - recycle rx dma buffers + * @priv: private structure + * @queue: rx queue index + */ +static void dma_recycle_rx_skbufs(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + int i; + + for (i = 0; i < priv->dma_rx_size; i++) { + struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i]; + + if (buf->page) { + page_pool_recycle_direct(rx_q->page_pool, buf->page); + buf->page = null; + } + + if (priv->sph && buf->sec_page) { + page_pool_recycle_direct(rx_q->page_pool, buf->sec_page); + buf->sec_page = null; + } + } +} + - for (queue = 0; queue < rx_count; queue++) { - struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; - - for (i = 0; i < priv->dma_rx_size; i++) { - struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i]; - - if (buf->page) { - page_pool_recycle_direct(rx_q->page_pool, buf->page); - buf->page = null; - } - - if (priv->sph && buf->sec_page) { - page_pool_recycle_direct(rx_q->page_pool, buf->sec_page); - buf->sec_page = null; - } - } - } + for (queue = 0; queue < rx_count; queue++) + dma_recycle_rx_skbufs(priv, queue);
|
Networking
|
80f573c995fc8e385d4aebc0ffce88f6b32bb183
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: refactor stmmac_init_rx_buffers for stmmac_reinit_rx_buffers
|
the per-queue rx buffer allocation in stmmac_reinit_rx_buffers() can be made to use stmmac_alloc_rx_buffers() by merging the page_pool alloc checks for "buf->page" and "buf->sec_page" in stmmac_init_rx_buffers().
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp zc support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 189
| 189
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c - buf->page = page_pool_dev_alloc_pages(rx_q->page_pool); - if (!buf->page) - return -enomem; - buf->page_offset = stmmac_rx_offset(priv); + if (!buf->page) { + buf->page = page_pool_dev_alloc_pages(rx_q->page_pool); + if (!buf->page) + return -enomem; + buf->page_offset = stmmac_rx_offset(priv); + } - if (priv->sph) { + if (priv->sph && !buf->sec_page) { - int i; - struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; - - for (i = 0; i < priv->dma_rx_size; i++) { - struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i]; - struct dma_desc *p; - - if (priv->extend_desc) - p = &((rx_q->dma_erx + i)->basic); - else - p = rx_q->dma_rx + i; - - if (!buf->page) { - buf->page = page_pool_dev_alloc_pages(rx_q->page_pool); - if (!buf->page) - goto err_reinit_rx_buffers; - - buf->addr = page_pool_get_dma_addr(buf->page) + - buf->page_offset; - } - - if (priv->sph && !buf->sec_page) { - buf->sec_page = page_pool_dev_alloc_pages(rx_q->page_pool); - if (!buf->sec_page) - goto err_reinit_rx_buffers; - - buf->sec_addr = page_pool_get_dma_addr(buf->sec_page); - } + int ret; - stmmac_set_desc_addr(priv, p, buf->addr); - if (priv->sph) - stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true); - else - stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false); - if (priv->dma_buf_sz == buf_size_16kib) - stmmac_init_desc3(priv, p); - } + ret = stmmac_alloc_rx_buffers(priv, queue, gfp_kernel); + if (ret < 0) + goto err_reinit_rx_buffers; - * free_dma_rx_desc_resources - free rx dma desc resources + * __free_dma_rx_desc_resources - free rx dma desc resources (per queue) + * @queue: rx queue index -static void free_dma_rx_desc_resources(struct stmmac_priv *priv) +static void __free_dma_rx_desc_resources(struct stmmac_priv *priv, u32 queue) - u32 rx_count = priv->plat->rx_queues_to_use; - u32 queue; + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; - /* free rx queue resources */ - for (queue = 0; queue < rx_count; queue++) { - struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + /* release the dma rx socket buffers */ + dma_free_rx_skbufs(priv, queue); - /* release the dma rx socket buffers */ - dma_free_rx_skbufs(priv, queue); + /* free dma regions of consistent memory previously allocated */ + if (!priv->extend_desc) + dma_free_coherent(priv->device, priv->dma_rx_size * + sizeof(struct dma_desc), + rx_q->dma_rx, rx_q->dma_rx_phy); + else + dma_free_coherent(priv->device, priv->dma_rx_size * + sizeof(struct dma_extended_desc), + rx_q->dma_erx, rx_q->dma_rx_phy); - /* free dma regions of consistent memory previously allocated */ - if (!priv->extend_desc) - dma_free_coherent(priv->device, priv->dma_rx_size * - sizeof(struct dma_desc), - rx_q->dma_rx, rx_q->dma_rx_phy); - else - dma_free_coherent(priv->device, priv->dma_rx_size * - sizeof(struct dma_extended_desc), - rx_q->dma_erx, rx_q->dma_rx_phy); + if (xdp_rxq_info_is_reg(&rx_q->xdp_rxq)) + xdp_rxq_info_unreg(&rx_q->xdp_rxq); - if (xdp_rxq_info_is_reg(&rx_q->xdp_rxq)) - xdp_rxq_info_unreg(&rx_q->xdp_rxq); + kfree(rx_q->buf_pool); + if (rx_q->page_pool) + page_pool_destroy(rx_q->page_pool); +} - kfree(rx_q->buf_pool); - if (rx_q->page_pool) - page_pool_destroy(rx_q->page_pool); - } +static void free_dma_rx_desc_resources(struct stmmac_priv *priv) +{ + u32 rx_count = priv->plat->rx_queues_to_use; + u32 queue; + + /* free rx queue resources */ + for (queue = 0; queue < rx_count; queue++) + __free_dma_rx_desc_resources(priv, queue); - * free_dma_tx_desc_resources - free tx dma desc resources + * __free_dma_tx_desc_resources - free tx dma desc resources (per queue) + * @queue: tx queue index -static void free_dma_tx_desc_resources(struct stmmac_priv *priv) +static void __free_dma_tx_desc_resources(struct stmmac_priv *priv, u32 queue) - u32 tx_count = priv->plat->tx_queues_to_use; - u32 queue; + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; + size_t size; + void *addr; - /* free tx queue resources */ - for (queue = 0; queue < tx_count; queue++) { - struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; - size_t size; - void *addr; + /* release the dma tx socket buffers */ + dma_free_tx_skbufs(priv, queue); + + if (priv->extend_desc) { + size = sizeof(struct dma_extended_desc); + addr = tx_q->dma_etx; + } else if (tx_q->tbs & stmmac_tbs_avail) { + size = sizeof(struct dma_edesc); + addr = tx_q->dma_entx; + } else { + size = sizeof(struct dma_desc); + addr = tx_q->dma_tx; + } - /* release the dma tx socket buffers */ - dma_free_tx_skbufs(priv, queue); + size *= priv->dma_tx_size; - if (priv->extend_desc) { - size = sizeof(struct dma_extended_desc); - addr = tx_q->dma_etx; - } else if (tx_q->tbs & stmmac_tbs_avail) { - size = sizeof(struct dma_edesc); - addr = tx_q->dma_entx; - } else { - size = sizeof(struct dma_desc); - addr = tx_q->dma_tx; - } + dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy); - size *= priv->dma_tx_size; + kfree(tx_q->tx_skbuff_dma); + kfree(tx_q->tx_skbuff); +} - dma_free_coherent(priv->device, size, addr, tx_q->dma_tx_phy); +static void free_dma_tx_desc_resources(struct stmmac_priv *priv) +{ + u32 tx_count = priv->plat->tx_queues_to_use; + u32 queue; - kfree(tx_q->tx_skbuff_dma); - kfree(tx_q->tx_skbuff); - } + /* free tx queue resources */ + for (queue = 0; queue < tx_count; queue++) + __free_dma_tx_desc_resources(priv, queue); - * alloc_dma_rx_desc_resources - alloc rx resources. + * __alloc_dma_rx_desc_resources - alloc rx resources (per queue). + * @queue: rx queue index -static int alloc_dma_rx_desc_resources(struct stmmac_priv *priv) +static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, u32 queue) + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + struct stmmac_channel *ch = &priv->channel[queue]; - u32 rx_count = priv->plat->rx_queues_to_use; - int ret = -enomem; - u32 queue; + struct page_pool_params pp_params = { 0 }; + unsigned int num_pages; + int ret; - /* rx queues buffers and dma */ - for (queue = 0; queue < rx_count; queue++) { - struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; - struct stmmac_channel *ch = &priv->channel[queue]; - struct page_pool_params pp_params = { 0 }; - unsigned int num_pages; - int ret; + rx_q->queue_index = queue; + rx_q->priv_data = priv; + + pp_params.flags = pp_flag_dma_map | pp_flag_dma_sync_dev; + pp_params.pool_size = priv->dma_rx_size; + num_pages = div_round_up(priv->dma_buf_sz, page_size); + pp_params.order = ilog2(num_pages); + pp_params.nid = dev_to_node(priv->device); + pp_params.dev = priv->device; + pp_params.dma_dir = xdp_prog ? dma_bidirectional : dma_from_device; + pp_params.offset = stmmac_rx_offset(priv); + pp_params.max_len = stmmac_max_rx_buf_size(num_pages); + + rx_q->page_pool = page_pool_create(&pp_params); + if (is_err(rx_q->page_pool)) { + ret = ptr_err(rx_q->page_pool); + rx_q->page_pool = null; + return ret; + } - rx_q->queue_index = queue; - rx_q->priv_data = priv; - - pp_params.flags = pp_flag_dma_map | pp_flag_dma_sync_dev; - pp_params.pool_size = priv->dma_rx_size; - num_pages = div_round_up(priv->dma_buf_sz, page_size); - pp_params.order = ilog2(num_pages); - pp_params.nid = dev_to_node(priv->device); - pp_params.dev = priv->device; - pp_params.dma_dir = xdp_prog ? dma_bidirectional : dma_from_device; - pp_params.offset = stmmac_rx_offset(priv); - pp_params.max_len = stmmac_max_rx_buf_size(num_pages); - - rx_q->page_pool = page_pool_create(&pp_params); - if (is_err(rx_q->page_pool)) { - ret = ptr_err(rx_q->page_pool); - rx_q->page_pool = null; - goto err_dma; - } + rx_q->buf_pool = kcalloc(priv->dma_rx_size, + sizeof(*rx_q->buf_pool), + gfp_kernel); + if (!rx_q->buf_pool) + return -enomem; - rx_q->buf_pool = kcalloc(priv->dma_rx_size, - sizeof(*rx_q->buf_pool), - gfp_kernel); - if (!rx_q->buf_pool) - goto err_dma; + if (priv->extend_desc) { + rx_q->dma_erx = dma_alloc_coherent(priv->device, + priv->dma_rx_size * + sizeof(struct dma_extended_desc), + &rx_q->dma_rx_phy, + gfp_kernel); + if (!rx_q->dma_erx) + return -enomem; - if (priv->extend_desc) { - rx_q->dma_erx = dma_alloc_coherent(priv->device, - priv->dma_rx_size * - sizeof(struct dma_extended_desc), - &rx_q->dma_rx_phy, - gfp_kernel); - if (!rx_q->dma_erx) - goto err_dma; + } else { + rx_q->dma_rx = dma_alloc_coherent(priv->device, + priv->dma_rx_size * + sizeof(struct dma_desc), + &rx_q->dma_rx_phy, + gfp_kernel); + if (!rx_q->dma_rx) + return -enomem; + } - } else { - rx_q->dma_rx = dma_alloc_coherent(priv->device, - priv->dma_rx_size * - sizeof(struct dma_desc), - &rx_q->dma_rx_phy, - gfp_kernel); - if (!rx_q->dma_rx) - goto err_dma; - } + ret = xdp_rxq_info_reg(&rx_q->xdp_rxq, priv->dev, + rx_q->queue_index, + ch->rx_napi.napi_id); + if (ret) { + netdev_err(priv->dev, "failed to register xdp rxq info "); + return -einval; + } - ret = xdp_rxq_info_reg(&rx_q->xdp_rxq, priv->dev, - rx_q->queue_index, - ch->rx_napi.napi_id); - if (ret) { - netdev_err(priv->dev, "failed to register xdp rxq info "); + return 0; +} + +static int alloc_dma_rx_desc_resources(struct stmmac_priv *priv) +{ + u32 rx_count = priv->plat->rx_queues_to_use; + u32 queue; + int ret; + + /* rx queues buffers and dma */ + for (queue = 0; queue < rx_count; queue++) { + ret = __alloc_dma_rx_desc_resources(priv, queue); + if (ret) - } - * alloc_dma_tx_desc_resources - alloc tx resources. + * __alloc_dma_tx_desc_resources - alloc tx resources (per queue). + * @queue: tx queue index -static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv) +static int __alloc_dma_tx_desc_resources(struct stmmac_priv *priv, u32 queue) - u32 tx_count = priv->plat->tx_queues_to_use; - int ret = -enomem; - u32 queue; + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; + size_t size; + void *addr; - /* tx queues buffers and dma */ - for (queue = 0; queue < tx_count; queue++) { - struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; - size_t size; - void *addr; + tx_q->queue_index = queue; + tx_q->priv_data = priv; - tx_q->queue_index = queue; - tx_q->priv_data = priv; + tx_q->tx_skbuff_dma = kcalloc(priv->dma_tx_size, + sizeof(*tx_q->tx_skbuff_dma), + gfp_kernel); + if (!tx_q->tx_skbuff_dma) + return -enomem; - tx_q->tx_skbuff_dma = kcalloc(priv->dma_tx_size, - sizeof(*tx_q->tx_skbuff_dma), - gfp_kernel); - if (!tx_q->tx_skbuff_dma) - goto err_dma; + tx_q->tx_skbuff = kcalloc(priv->dma_tx_size, + sizeof(struct sk_buff *), + gfp_kernel); + if (!tx_q->tx_skbuff) + return -enomem; - tx_q->tx_skbuff = kcalloc(priv->dma_tx_size, - sizeof(struct sk_buff *), - gfp_kernel); - if (!tx_q->tx_skbuff) - goto err_dma; + if (priv->extend_desc) + size = sizeof(struct dma_extended_desc); + else if (tx_q->tbs & stmmac_tbs_avail) + size = sizeof(struct dma_edesc); + else + size = sizeof(struct dma_desc); - if (priv->extend_desc) - size = sizeof(struct dma_extended_desc); - else if (tx_q->tbs & stmmac_tbs_avail) - size = sizeof(struct dma_edesc); - else - size = sizeof(struct dma_desc); + size *= priv->dma_tx_size; - size *= priv->dma_tx_size; + addr = dma_alloc_coherent(priv->device, size, + &tx_q->dma_tx_phy, gfp_kernel); + if (!addr) + return -enomem; - addr = dma_alloc_coherent(priv->device, size, - &tx_q->dma_tx_phy, gfp_kernel); - if (!addr) - goto err_dma; + if (priv->extend_desc) + tx_q->dma_etx = addr; + else if (tx_q->tbs & stmmac_tbs_avail) + tx_q->dma_entx = addr; + else + tx_q->dma_tx = addr; - if (priv->extend_desc) - tx_q->dma_etx = addr; - else if (tx_q->tbs & stmmac_tbs_avail) - tx_q->dma_entx = addr; - else - tx_q->dma_tx = addr; + return 0; +} + +static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv) +{ + u32 tx_count = priv->plat->tx_queues_to_use; + u32 queue; + int ret; + + /* tx queues buffers and dma */ + for (queue = 0; queue < tx_count; queue++) { + ret = __alloc_dma_tx_desc_resources(priv, queue); + if (ret) + goto err_dma;
|
Networking
|
da5ec7f22a0f1a10a5a9c3063421e73ae054649d
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: rearrange rx and tx desc init into per-queue basis
|
below functions are made to be per-queue in preparation of xdp zc:
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp zc support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 100
| 80
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c - * init_dma_rx_desc_rings - init the rx descriptor rings - * @dev: net device structure + * __init_dma_rx_desc_rings - init the rx descriptor ring (per queue) + * @priv: driver private structure + * @queue: rx queue index -static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags) +static int __init_dma_rx_desc_rings(struct stmmac_priv *priv, u32 queue, gfp_t flags) - struct stmmac_priv *priv = netdev_priv(dev); - u32 rx_count = priv->plat->rx_queues_to_use; - int ret = -enomem; - int queue; + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + int ret; - /* rx initialization */ - "skb addresses: skb skb data dma data "); + "(%s) dma_rx_phy=0x%08x ", __func__, + (u32)rx_q->dma_rx_phy); - for (queue = 0; queue < rx_count; queue++) { - struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + stmmac_clear_rx_descriptors(priv, queue); + warn_on(xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq, + mem_type_page_pool, + rx_q->page_pool)); - netif_dbg(priv, probe, priv->dev, - "(%s) dma_rx_phy=0x%08x ", __func__, - (u32)rx_q->dma_rx_phy); + netdev_info(priv->dev, + "register mem_type_page_pool rxq-%d ", + rx_q->queue_index); - stmmac_clear_rx_descriptors(priv, queue); + ret = stmmac_alloc_rx_buffers(priv, queue, flags); + if (ret < 0) + return -enomem; - warn_on(xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq, - mem_type_page_pool, - rx_q->page_pool)); + rx_q->cur_rx = 0; + rx_q->dirty_rx = 0; - netdev_info(priv->dev, - "register mem_type_page_pool rxq-%d ", - rx_q->queue_index); + /* setup the chained descriptor addresses */ + if (priv->mode == stmmac_chain_mode) { + if (priv->extend_desc) + stmmac_mode_init(priv, rx_q->dma_erx, + rx_q->dma_rx_phy, + priv->dma_rx_size, 1); + else + stmmac_mode_init(priv, rx_q->dma_rx, + rx_q->dma_rx_phy, + priv->dma_rx_size, 0); + } - ret = stmmac_alloc_rx_buffers(priv, queue, flags); - if (ret < 0) - goto err_init_rx_buffers; + return 0; +} - rx_q->cur_rx = 0; - rx_q->dirty_rx = 0; +static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags) +{ + struct stmmac_priv *priv = netdev_priv(dev); + u32 rx_count = priv->plat->rx_queues_to_use; + u32 queue; + int ret; - /* setup the chained descriptor addresses */ - if (priv->mode == stmmac_chain_mode) { - if (priv->extend_desc) - stmmac_mode_init(priv, rx_q->dma_erx, - rx_q->dma_rx_phy, - priv->dma_rx_size, 1); - else - stmmac_mode_init(priv, rx_q->dma_rx, - rx_q->dma_rx_phy, - priv->dma_rx_size, 0); - } + /* rx initialization */ + netif_dbg(priv, probe, priv->dev, + "skb addresses: skb skb data dma data "); + + for (queue = 0; queue < rx_count; queue++) { + ret = __init_dma_rx_desc_rings(priv, queue, flags); + if (ret) + goto err_init_rx_buffers; - * init_dma_tx_desc_rings - init the tx descriptor rings - * @dev: net device structure. + * __init_dma_tx_desc_rings - init the tx descriptor ring (per queue) + * @priv: driver private structure + * @queue : tx queue index -static int init_dma_tx_desc_rings(struct net_device *dev) +static int __init_dma_tx_desc_rings(struct stmmac_priv *priv, u32 queue) - struct stmmac_priv *priv = netdev_priv(dev); - u32 tx_queue_cnt = priv->plat->tx_queues_to_use; - u32 queue; + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; - for (queue = 0; queue < tx_queue_cnt; queue++) { - struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; - - netif_dbg(priv, probe, priv->dev, - "(%s) dma_tx_phy=0x%08x ", __func__, - (u32)tx_q->dma_tx_phy); - - /* setup the chained descriptor addresses */ - if (priv->mode == stmmac_chain_mode) { - if (priv->extend_desc) - stmmac_mode_init(priv, tx_q->dma_etx, - tx_q->dma_tx_phy, - priv->dma_tx_size, 1); - else if (!(tx_q->tbs & stmmac_tbs_avail)) - stmmac_mode_init(priv, tx_q->dma_tx, - tx_q->dma_tx_phy, - priv->dma_tx_size, 0); - } + netif_dbg(priv, probe, priv->dev, + "(%s) dma_tx_phy=0x%08x ", __func__, + (u32)tx_q->dma_tx_phy); - for (i = 0; i < priv->dma_tx_size; i++) { - struct dma_desc *p; - if (priv->extend_desc) - p = &((tx_q->dma_etx + i)->basic); - else if (tx_q->tbs & stmmac_tbs_avail) - p = &((tx_q->dma_entx + i)->basic); - else - p = tx_q->dma_tx + i; + /* setup the chained descriptor addresses */ + if (priv->mode == stmmac_chain_mode) { + if (priv->extend_desc) + stmmac_mode_init(priv, tx_q->dma_etx, + tx_q->dma_tx_phy, + priv->dma_tx_size, 1); + else if (!(tx_q->tbs & stmmac_tbs_avail)) + stmmac_mode_init(priv, tx_q->dma_tx, + tx_q->dma_tx_phy, + priv->dma_tx_size, 0); + } - stmmac_clear_desc(priv, p); + for (i = 0; i < priv->dma_tx_size; i++) { + struct dma_desc *p; - tx_q->tx_skbuff_dma[i].buf = 0; - tx_q->tx_skbuff_dma[i].map_as_page = false; - tx_q->tx_skbuff_dma[i].len = 0; - tx_q->tx_skbuff_dma[i].last_segment = false; - tx_q->tx_skbuff[i] = null; - } + if (priv->extend_desc) + p = &((tx_q->dma_etx + i)->basic); + else if (tx_q->tbs & stmmac_tbs_avail) + p = &((tx_q->dma_entx + i)->basic); + else + p = tx_q->dma_tx + i; - tx_q->dirty_tx = 0; - tx_q->cur_tx = 0; - tx_q->mss = 0; + stmmac_clear_desc(priv, p); - netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue)); + tx_q->tx_skbuff_dma[i].buf = 0; + tx_q->tx_skbuff_dma[i].map_as_page = false; + tx_q->tx_skbuff_dma[i].len = 0; + tx_q->tx_skbuff_dma[i].last_segment = false; + tx_q->tx_skbuff[i] = null; + tx_q->dirty_tx = 0; + tx_q->cur_tx = 0; + tx_q->mss = 0; + + netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue)); + + return 0; +} + +static int init_dma_tx_desc_rings(struct net_device *dev) +{ + struct stmmac_priv *priv = netdev_priv(dev); + u32 tx_queue_cnt; + u32 queue; + + tx_queue_cnt = priv->plat->tx_queues_to_use; + + for (queue = 0; queue < tx_queue_cnt; queue++) + __init_dma_tx_desc_rings(priv, queue); +
|
Networking
|
de0b90e52a116a951ca8b13c924c359d5fc39fa0
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: refactor __stmmac_xdp_run_prog for xdp zc
|
prepare stmmac_xdp_run_prog() for af_xdp zero-copy support which will be added by upcoming patches by splitting out the xdp verdict processing into __stmmac_xdp_run_prog() and it callable for xdp zc path which does not need to verify bpf_prog is not null.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp zc support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 23
| 12
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c -static struct sk_buff *stmmac_xdp_run_prog(struct stmmac_priv *priv, - struct xdp_buff *xdp) +/* this function assumes rcu_read_lock() is held by the caller. */ +static int __stmmac_xdp_run_prog(struct stmmac_priv *priv, + struct bpf_prog *prog, + struct xdp_buff *xdp) - struct bpf_prog *prog; - int res; - - rcu_read_lock(); - - prog = read_once(priv->xdp_prog); - if (!prog) { - res = stmmac_xdp_pass; - goto unlock; - } + int res; + return res; +} + +static struct sk_buff *stmmac_xdp_run_prog(struct stmmac_priv *priv, + struct xdp_buff *xdp) +{ + struct bpf_prog *prog; + int res; + + rcu_read_lock(); + + prog = read_once(priv->xdp_prog); + if (!prog) { + res = stmmac_xdp_pass; + goto unlock; + } + + res = __stmmac_xdp_run_prog(priv, prog, xdp);
|
Networking
|
bba71cac680f30de93486c989ee283cccedc5f77
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: enable rx via af_xdp zero-copy
|
this patch adds the support for receiving packet via af_xdp zero-copy mechanism.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp zc support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 4
| 679
| 29
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h - struct page *page; - dma_addr_t addr; - __u32 page_offset; + union { + struct { + struct page *page; + dma_addr_t addr; + __u32 page_offset; + }; + struct xdp_buff *xdp; + }; + struct xsk_buff_pool *xsk_pool; + unsigned int buf_alloc_num; + unsigned long *af_xdp_zc_qps; +void stmmac_disable_rx_queue(struct stmmac_priv *priv, u32 queue); +void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue); +int stmmac_xsk_wakeup(struct net_device *dev, u32 queue, u32 flags); + diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +#include <net/xdp_sock_drv.h> +#define stmmac_rx_fill_batch 16 + -/** - * stmmac_disable_all_queues - disable all queues - * @priv: driver private structure - */ -static void stmmac_disable_all_queues(struct stmmac_priv *priv) +static void __stmmac_disable_all_queues(struct stmmac_priv *priv) +/** + * stmmac_disable_all_queues - disable all queues + * @priv: driver private structure + */ +static void stmmac_disable_all_queues(struct stmmac_priv *priv) +{ + u32 rx_queues_cnt = priv->plat->rx_queues_to_use; + struct stmmac_rx_queue *rx_q; + u32 queue; + + /* synchronize_rcu() needed for pending xdp buffers to drain */ + for (queue = 0; queue < rx_queues_cnt; queue++) { + rx_q = &priv->rx_queue[queue]; + if (rx_q->xsk_pool) { + synchronize_rcu(); + break; + } + } + + __stmmac_disable_all_queues(priv); +} + + + rx_q->buf_alloc_num++; +/** + * dma_free_rx_xskbufs - free rx dma buffers from xsk pool + * @priv: private structure + * @queue: rx queue index + */ +static void dma_free_rx_xskbufs(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + int i; + + for (i = 0; i < priv->dma_rx_size; i++) { + struct stmmac_rx_buffer *buf = &rx_q->buf_pool[i]; + + if (!buf->xdp) + continue; + + xsk_buff_free(buf->xdp); + buf->xdp = null; + } +} + +static int stmmac_alloc_rx_buffers_zc(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + int i; + + for (i = 0; i < priv->dma_rx_size; i++) { + struct stmmac_rx_buffer *buf; + dma_addr_t dma_addr; + struct dma_desc *p; + + if (priv->extend_desc) + p = (struct dma_desc *)(rx_q->dma_erx + i); + else + p = rx_q->dma_rx + i; + + buf = &rx_q->buf_pool[i]; + + buf->xdp = xsk_buff_alloc(rx_q->xsk_pool); + if (!buf->xdp) + return -enomem; + + dma_addr = xsk_buff_xdp_get_dma(buf->xdp); + stmmac_set_desc_addr(priv, p, dma_addr); + rx_q->buf_alloc_num++; + } + + return 0; +} + - for (queue = 0; queue < rx_count; queue++) - dma_recycle_rx_skbufs(priv, queue); + for (queue = 0; queue < rx_count; queue++) { + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + + if (rx_q->xsk_pool) + dma_free_rx_xskbufs(priv, queue); + else + dma_recycle_rx_skbufs(priv, queue); + + rx_q->buf_alloc_num = 0; + } + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; - ret = stmmac_alloc_rx_buffers(priv, queue, gfp_kernel); - if (ret < 0) - goto err_reinit_rx_buffers; + if (rx_q->xsk_pool) { + /* rx xdp zc buffer pool may not be populated, e.g. + * xdpsock tx-only. + */ + stmmac_alloc_rx_buffers_zc(priv, queue); + } else { + ret = stmmac_alloc_rx_buffers(priv, queue, gfp_kernel); + if (ret < 0) + goto err_reinit_rx_buffers; + } +static struct xsk_buff_pool *stmmac_get_xsk_pool(struct stmmac_priv *priv, u32 queue) +{ + if (!stmmac_xdp_is_enabled(priv) || !test_bit(queue, priv->af_xdp_zc_qps)) + return null; + + return xsk_get_pool_from_qid(priv->dev, queue); +} + - warn_on(xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq, - mem_type_page_pool, - rx_q->page_pool)); + xdp_rxq_info_unreg_mem_model(&rx_q->xdp_rxq); - netdev_info(priv->dev, - "register mem_type_page_pool rxq-%d ", - rx_q->queue_index); + rx_q->xsk_pool = stmmac_get_xsk_pool(priv, queue); - ret = stmmac_alloc_rx_buffers(priv, queue, flags); - if (ret < 0) - return -enomem; + if (rx_q->xsk_pool) { + warn_on(xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq, + mem_type_xsk_buff_pool, + null)); + netdev_info(priv->dev, + "register mem_type_xsk_buff_pool rxq-%d ", + rx_q->queue_index); + xsk_pool_set_rxq_info(rx_q->xsk_pool, &rx_q->xdp_rxq); + } else { + warn_on(xdp_rxq_info_reg_mem_model(&rx_q->xdp_rxq, + mem_type_page_pool, + rx_q->page_pool)); + netdev_info(priv->dev, + "register mem_type_page_pool rxq-%d ", + rx_q->queue_index); + } + + if (rx_q->xsk_pool) { + /* rx xdp zc buffer pool may not be populated, e.g. + * xdpsock tx-only. + */ + stmmac_alloc_rx_buffers_zc(priv, queue); + } else { + ret = stmmac_alloc_rx_buffers(priv, queue, flags); + if (ret < 0) + return -enomem; + } - dma_free_rx_skbufs(priv, queue); + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + + if (rx_q->xsk_pool) + dma_free_rx_xskbufs(priv, queue); + else + dma_free_rx_skbufs(priv, queue); + + rx_q->buf_alloc_num = 0; + rx_q->xsk_pool = null; - dma_free_rx_skbufs(priv, queue); + if (rx_q->xsk_pool) + dma_free_rx_xskbufs(priv, queue); + else + dma_free_rx_skbufs(priv, queue); + + rx_q->buf_alloc_num = 0; + rx_q->xsk_pool = null; + struct stmmac_rx_queue *rx_q = &priv->rx_queue[chan]; + u32 buf_size; + - stmmac_set_dma_bfsize(priv, priv->ioaddr, priv->dma_buf_sz, - chan); + + if (rx_q->xsk_pool) { + buf_size = xsk_pool_get_rx_frame_size(rx_q->xsk_pool); + stmmac_set_dma_bfsize(priv, priv->ioaddr, + buf_size, + chan); + } else { + stmmac_set_dma_bfsize(priv, priv->ioaddr, + priv->dma_buf_sz, + chan); + } - (priv->dma_rx_size * + (rx_q->buf_alloc_num * +static struct sk_buff *stmmac_construct_skb_zc(struct stmmac_channel *ch, + struct xdp_buff *xdp) +{ + unsigned int metasize = xdp->data - xdp->data_meta; + unsigned int datasize = xdp->data_end - xdp->data; + struct sk_buff *skb; + + skb = __napi_alloc_skb(&ch->rx_napi, + xdp->data_end - xdp->data_hard_start, + gfp_atomic | __gfp_nowarn); + if (unlikely(!skb)) + return null; + + skb_reserve(skb, xdp->data - xdp->data_hard_start); + memcpy(__skb_put(skb, datasize), xdp->data, datasize); + if (metasize) + skb_metadata_set(skb, metasize); + + return skb; +} + +static void stmmac_dispatch_skb_zc(struct stmmac_priv *priv, u32 queue, + struct dma_desc *p, struct dma_desc *np, + struct xdp_buff *xdp) +{ + struct stmmac_channel *ch = &priv->channel[queue]; + unsigned int len = xdp->data_end - xdp->data; + enum pkt_hash_types hash_type; + int coe = priv->hw->rx_csum; + struct sk_buff *skb; + u32 hash; + + skb = stmmac_construct_skb_zc(ch, xdp); + if (!skb) { + priv->dev->stats.rx_dropped++; + return; + } + + stmmac_get_rx_hwtstamp(priv, p, np, skb); + stmmac_rx_vlan(priv->dev, skb); + skb->protocol = eth_type_trans(skb, priv->dev); + + if (unlikely(!coe)) + skb_checksum_none_assert(skb); + else + skb->ip_summed = checksum_unnecessary; + + if (!stmmac_get_rx_hash(priv, p, &hash, &hash_type)) + skb_set_hash(skb, hash, hash_type); + + skb_record_rx_queue(skb, queue); + napi_gro_receive(&ch->rx_napi, skb); + + priv->dev->stats.rx_packets++; + priv->dev->stats.rx_bytes += len; +} + +static bool stmmac_rx_refill_zc(struct stmmac_priv *priv, u32 queue, u32 budget) +{ + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + unsigned int entry = rx_q->dirty_rx; + struct dma_desc *rx_desc = null; + bool ret = true; + + budget = min(budget, stmmac_rx_dirty(priv, queue)); + + while (budget-- > 0 && entry != rx_q->cur_rx) { + struct stmmac_rx_buffer *buf = &rx_q->buf_pool[entry]; + dma_addr_t dma_addr; + bool use_rx_wd; + + if (!buf->xdp) { + buf->xdp = xsk_buff_alloc(rx_q->xsk_pool); + if (!buf->xdp) { + ret = false; + break; + } + } + + if (priv->extend_desc) + rx_desc = (struct dma_desc *)(rx_q->dma_erx + entry); + else + rx_desc = rx_q->dma_rx + entry; + + dma_addr = xsk_buff_xdp_get_dma(buf->xdp); + stmmac_set_desc_addr(priv, rx_desc, dma_addr); + stmmac_set_desc_sec_addr(priv, rx_desc, 0, false); + stmmac_refill_desc3(priv, rx_q, rx_desc); + + rx_q->rx_count_frames++; + rx_q->rx_count_frames += priv->rx_coal_frames[queue]; + if (rx_q->rx_count_frames > priv->rx_coal_frames[queue]) + rx_q->rx_count_frames = 0; + + use_rx_wd = !priv->rx_coal_frames[queue]; + use_rx_wd |= rx_q->rx_count_frames > 0; + if (!priv->use_riwt) + use_rx_wd = false; + + dma_wmb(); + stmmac_set_rx_owner(priv, rx_desc, use_rx_wd); + + entry = stmmac_get_entry(entry, priv->dma_rx_size); + } + + if (rx_desc) { + rx_q->dirty_rx = entry; + rx_q->rx_tail_addr = rx_q->dma_rx_phy + + (rx_q->dirty_rx * sizeof(struct dma_desc)); + stmmac_set_rx_tail_ptr(priv, priv->ioaddr, rx_q->rx_tail_addr, queue); + } + + return ret; +} + +static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue) +{ + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + unsigned int count = 0, error = 0, len = 0; + int dirty = stmmac_rx_dirty(priv, queue); + unsigned int next_entry = rx_q->cur_rx; + unsigned int desc_size; + struct bpf_prog *prog; + bool failure = false; + int xdp_status = 0; + int status = 0; + + if (netif_msg_rx_status(priv)) { + void *rx_head; + + netdev_dbg(priv->dev, "%s: descriptor ring: ", __func__); + if (priv->extend_desc) { + rx_head = (void *)rx_q->dma_erx; + desc_size = sizeof(struct dma_extended_desc); + } else { + rx_head = (void *)rx_q->dma_rx; + desc_size = sizeof(struct dma_desc); + } + + stmmac_display_ring(priv, rx_head, priv->dma_rx_size, true, + rx_q->dma_rx_phy, desc_size); + } + while (count < limit) { + struct stmmac_rx_buffer *buf; + unsigned int buf1_len = 0; + struct dma_desc *np, *p; + int entry; + int res; + + if (!count && rx_q->state_saved) { + error = rx_q->state.error; + len = rx_q->state.len; + } else { + rx_q->state_saved = false; + error = 0; + len = 0; + } + + if (count >= limit) + break; + +read_again: + buf1_len = 0; + entry = next_entry; + buf = &rx_q->buf_pool[entry]; + + if (dirty >= stmmac_rx_fill_batch) { + failure = failure || + !stmmac_rx_refill_zc(priv, queue, dirty); + dirty = 0; + } + + if (priv->extend_desc) + p = (struct dma_desc *)(rx_q->dma_erx + entry); + else + p = rx_q->dma_rx + entry; + + /* read the status of the incoming frame */ + status = stmmac_rx_status(priv, &priv->dev->stats, + &priv->xstats, p); + /* check if managed by the dma otherwise go ahead */ + if (unlikely(status & dma_own)) + break; + + /* prefetch the next rx descriptor */ + rx_q->cur_rx = stmmac_get_entry(rx_q->cur_rx, + priv->dma_rx_size); + next_entry = rx_q->cur_rx; + + if (priv->extend_desc) + np = (struct dma_desc *)(rx_q->dma_erx + next_entry); + else + np = rx_q->dma_rx + next_entry; + + prefetch(np); + + if (priv->extend_desc) + stmmac_rx_extended_status(priv, &priv->dev->stats, + &priv->xstats, + rx_q->dma_erx + entry); + if (unlikely(status == discard_frame)) { + xsk_buff_free(buf->xdp); + buf->xdp = null; + dirty++; + error = 1; + if (!priv->hwts_rx_en) + priv->dev->stats.rx_errors++; + } + + if (unlikely(error && (status & rx_not_ls))) + goto read_again; + if (unlikely(error)) { + count++; + continue; + } + + /* ensure a valid xsk buffer before proceed */ + if (!buf->xdp) + break; + + /* xsk pool expects rx frame 1:1 mapped to xsk buffer */ + if (likely(status & rx_not_ls)) { + xsk_buff_free(buf->xdp); + buf->xdp = null; + dirty++; + count++; + goto read_again; + } + + /* xdp zc frame only support primary buffers for now */ + buf1_len = stmmac_rx_buf1_len(priv, p, status, len); + len += buf1_len; + + /* acs is set; gmac core strips pad/fcs for ieee 802.3 + * type frames (llc/llc-snap) + * + * llc_snap is never checked in gmac >= 4, so this acs + * feature is always disabled and packets need to be + * stripped manually. + */ + if (likely(!(status & rx_not_ls)) && + (likely(priv->synopsys_id >= dwmac_core_4_00) || + unlikely(status != llc_snap))) { + buf1_len -= eth_fcs_len; + len -= eth_fcs_len; + } + + /* rx buffer is good and fit into a xsk pool buffer */ + buf->xdp->data_end = buf->xdp->data + buf1_len; + xsk_buff_dma_sync_for_cpu(buf->xdp, rx_q->xsk_pool); + + rcu_read_lock(); + prog = read_once(priv->xdp_prog); + res = __stmmac_xdp_run_prog(priv, prog, buf->xdp); + rcu_read_unlock(); + + switch (res) { + case stmmac_xdp_pass: + stmmac_dispatch_skb_zc(priv, queue, p, np, buf->xdp); + xsk_buff_free(buf->xdp); + break; + case stmmac_xdp_consumed: + xsk_buff_free(buf->xdp); + priv->dev->stats.rx_dropped++; + break; + case stmmac_xdp_tx: + case stmmac_xdp_redirect: + xdp_status |= res; + break; + } + + buf->xdp = null; + dirty++; + count++; + } + + if (status & rx_not_ls) { + rx_q->state_saved = true; + rx_q->state.error = error; + rx_q->state.len = len; + } + + stmmac_finalize_xdp_rx(priv, xdp_status); + + if (xsk_uses_need_wakeup(rx_q->xsk_pool)) { + if (failure || stmmac_rx_dirty(priv, queue) > 0) + xsk_set_rx_need_wakeup(rx_q->xsk_pool); + else + xsk_clear_rx_need_wakeup(rx_q->xsk_pool); + + return (int)count; + } + + return failure ? limit : (int)count; +} + + struct stmmac_rx_queue *rx_q; - work_done = stmmac_rx(priv, budget, chan); + rx_q = &priv->rx_queue[chan]; + + work_done = rx_q->xsk_pool ? + stmmac_rx_zc(priv, budget, chan) : + stmmac_rx(priv, budget, chan); - stmmac_disable_all_queues(priv); + __stmmac_disable_all_queues(priv); + case xdp_setup_xsk_pool: + return stmmac_xdp_setup_pool(priv, bpf->xsk.pool, + bpf->xsk.queue_id); +void stmmac_disable_rx_queue(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_channel *ch = &priv->channel[queue]; + unsigned long flags; + + spin_lock_irqsave(&ch->lock, flags); + stmmac_disable_dma_irq(priv, priv->ioaddr, queue, 1, 0); + spin_unlock_irqrestore(&ch->lock, flags); + + stmmac_stop_rx_dma(priv, queue); + __free_dma_rx_desc_resources(priv, queue); +} + +void stmmac_enable_rx_queue(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + struct stmmac_channel *ch = &priv->channel[queue]; + unsigned long flags; + u32 buf_size; + int ret; + + ret = __alloc_dma_rx_desc_resources(priv, queue); + if (ret) { + netdev_err(priv->dev, "failed to alloc rx desc. "); + return; + } + + ret = __init_dma_rx_desc_rings(priv, queue, gfp_kernel); + if (ret) { + __free_dma_rx_desc_resources(priv, queue); + netdev_err(priv->dev, "failed to init rx desc. "); + return; + } + + stmmac_clear_rx_descriptors(priv, queue); + + stmmac_init_rx_chan(priv, priv->ioaddr, priv->plat->dma_cfg, + rx_q->dma_rx_phy, rx_q->queue_index); + + rx_q->rx_tail_addr = rx_q->dma_rx_phy + (rx_q->buf_alloc_num * + sizeof(struct dma_desc)); + stmmac_set_rx_tail_ptr(priv, priv->ioaddr, + rx_q->rx_tail_addr, rx_q->queue_index); + + if (rx_q->xsk_pool && rx_q->buf_alloc_num) { + buf_size = xsk_pool_get_rx_frame_size(rx_q->xsk_pool); + stmmac_set_dma_bfsize(priv, priv->ioaddr, + buf_size, + rx_q->queue_index); + } else { + stmmac_set_dma_bfsize(priv, priv->ioaddr, + priv->dma_buf_sz, + rx_q->queue_index); + } + + stmmac_start_rx_dma(priv, queue); + + spin_lock_irqsave(&ch->lock, flags); + stmmac_enable_dma_irq(priv, priv->ioaddr, queue, 1, 0); + spin_unlock_irqrestore(&ch->lock, flags); +} + +int stmmac_xsk_wakeup(struct net_device *dev, u32 queue, u32 flags) +{ + struct stmmac_priv *priv = netdev_priv(dev); + struct stmmac_rx_queue *rx_q; + struct stmmac_channel *ch; + + if (test_bit(stmmac_down, &priv->state) || + !netif_carrier_ok(priv->dev)) + return -enetdown; + + if (!stmmac_xdp_is_enabled(priv)) + return -enxio; + + if (queue >= priv->plat->rx_queues_to_use) + return -einval; + + rx_q = &priv->rx_queue[queue]; + ch = &priv->channel[queue]; + + if (!rx_q->xsk_pool) + return -enxio; + + if (flags & xdp_wakeup_rx && + !napi_if_scheduled_mark_missed(&ch->rx_napi)) { + /* eqos does not have per-dma channel sw interrupt, + * so we schedule rx napi straight-away. + */ + if (likely(napi_schedule_prep(&ch->rx_napi))) + __napi_schedule(&ch->rx_napi); + } + + return 0; +} + + .ndo_xsk_wakeup = stmmac_xsk_wakeup, + priv->af_xdp_zc_qps = bitmap_zalloc(mtl_max_tx_queues, gfp_kernel); + if (!priv->af_xdp_zc_qps) + return -enomem; + diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c +#include <net/xdp_sock_drv.h> + +static int stmmac_xdp_enable_pool(struct stmmac_priv *priv, + struct xsk_buff_pool *pool, u16 queue) +{ + struct stmmac_channel *ch = &priv->channel[queue]; + bool need_update; + u32 frame_size; + int err; + + if (queue >= priv->plat->rx_queues_to_use) + return -einval; + + frame_size = xsk_pool_get_rx_frame_size(pool); + /* xdp zc does not span multiple frame, make sure xsk pool buffer + * size can at least store q-in-q frame. + */ + if (frame_size < eth_frame_len + vlan_hlen * 2) + return -eopnotsupp; + + err = xsk_pool_dma_map(pool, priv->device, stmmac_rx_dma_attr); + if (err) { + netdev_err(priv->dev, "failed to map xsk pool "); + return err; + } + + need_update = netif_running(priv->dev) && stmmac_xdp_is_enabled(priv); + + if (need_update) { + stmmac_disable_rx_queue(priv, queue); + napi_disable(&ch->rx_napi); + } + + set_bit(queue, priv->af_xdp_zc_qps); + + if (need_update) { + napi_enable(&ch->rx_napi); + stmmac_enable_rx_queue(priv, queue); + + err = stmmac_xsk_wakeup(priv->dev, queue, xdp_wakeup_rx); + if (err) + return err; + } + + return 0; +} + +static int stmmac_xdp_disable_pool(struct stmmac_priv *priv, u16 queue) +{ + struct stmmac_channel *ch = &priv->channel[queue]; + struct xsk_buff_pool *pool; + bool need_update; + + if (queue >= priv->plat->rx_queues_to_use) + return -einval; + + pool = xsk_get_pool_from_qid(priv->dev, queue); + if (!pool) + return -einval; + + need_update = netif_running(priv->dev) && stmmac_xdp_is_enabled(priv); + + if (need_update) { + stmmac_disable_rx_queue(priv, queue); + synchronize_rcu(); + napi_disable(&ch->rx_napi); + } + + xsk_pool_dma_unmap(pool, stmmac_rx_dma_attr); + + clear_bit(queue, priv->af_xdp_zc_qps); + + if (need_update) { + napi_enable(&ch->rx_napi); + stmmac_enable_rx_queue(priv, queue); + } + + return 0; +} + +int stmmac_xdp_setup_pool(struct stmmac_priv *priv, struct xsk_buff_pool *pool, + u16 queue) +{ + return pool ? stmmac_xdp_enable_pool(priv, pool, queue) : + stmmac_xdp_disable_pool(priv, queue); +} + diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.h +#define stmmac_rx_dma_attr (dma_attr_skip_cpu_sync | dma_attr_weak_ordering) +int stmmac_xdp_setup_pool(struct stmmac_priv *priv, struct xsk_buff_pool *pool, + u16 queue);
|
Networking
|
bba2556efad66e7eaa56fece13f7708caa1187f8
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add tx via xdp zero-copy socket
|
we add the support of xdp zc tx submission and cleaning into stmmac_tx_clean(). the function is made to clean as many tx complete frames as possible, i.e. limit by priv->dma_tx_size instead of napi budget. for tx ring that is associated with xsk pool, the function stmmac_xdp_xmit_zc() is introduced to tx frame buffers from xsk pool by using xsk_tx_peek_desc(). to make stmmac_tx_clean() support the cleaning of xsk tx frames, stmmac_txbuf_t_xsk_tx tx buffer type is introduced.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add xdp zc support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 3
| 310
| 29
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h + stmmac_txbuf_t_xsk_tx, + struct xsk_buff_pool *xsk_pool; + u32 xsk_frames_done; + struct napi_struct rxtx_napi ____cacheline_aligned_in_smp; +void stmmac_disable_tx_queue(struct stmmac_priv *priv, u32 queue); +void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +/* limit to make sure xdp tx and slow path can coexist */ +#define stmmac_xsk_tx_budget_max 256 +#define stmmac_tx_xsk_avail 16 +static void stmmac_tx_timer_arm(struct stmmac_priv *priv, u32 queue); +static void stmmac_flush_tx_descriptors(struct stmmac_priv *priv, int queue); + if (stmmac_xdp_is_enabled(priv) && + test_bit(queue, priv->af_xdp_zc_qps)) { + napi_disable(&ch->rxtx_napi); + continue; + } + + if (stmmac_xdp_is_enabled(priv) && + test_bit(queue, priv->af_xdp_zc_qps)) { + napi_enable(&ch->rxtx_napi); + continue; + } + + if (tx_q->tx_skbuff_dma[i].buf_type == stmmac_txbuf_t_xsk_tx) + tx_q->xsk_frames_done++; + + tx_q->xsk_pool = stmmac_get_xsk_pool(priv, queue); + + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; + tx_q->xsk_frames_done = 0; + + + if (tx_q->xsk_pool && tx_q->xsk_frames_done) { + xsk_tx_completed(tx_q->xsk_pool, tx_q->xsk_frames_done); + tx_q->xsk_frames_done = 0; + tx_q->xsk_pool = null; + } + unsigned int napi_id; + if (stmmac_xdp_is_enabled(priv) && + test_bit(queue, priv->af_xdp_zc_qps)) + napi_id = ch->rxtx_napi.napi_id; + else + napi_id = ch->rx_napi.napi_id; + - ch->rx_napi.napi_id); + napi_id); +static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget) +{ + struct netdev_queue *nq = netdev_get_tx_queue(priv->dev, queue); + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; + struct xsk_buff_pool *pool = tx_q->xsk_pool; + unsigned int entry = tx_q->cur_tx; + struct dma_desc *tx_desc = null; + struct xdp_desc xdp_desc; + bool work_done = true; + + /* avoids tx time-out as we are sharing with slow path */ + nq->trans_start = jiffies; + + budget = min(budget, stmmac_tx_avail(priv, queue)); + + while (budget-- > 0) { + dma_addr_t dma_addr; + bool set_ic; + + /* we are sharing with slow path and stop xsk tx desc submission when + * available tx ring is less than threshold. + */ + if (unlikely(stmmac_tx_avail(priv, queue) < stmmac_tx_xsk_avail) || + !netif_carrier_ok(priv->dev)) { + work_done = false; + break; + } + + if (!xsk_tx_peek_desc(pool, &xdp_desc)) + break; + + if (likely(priv->extend_desc)) + tx_desc = (struct dma_desc *)(tx_q->dma_etx + entry); + else if (tx_q->tbs & stmmac_tbs_avail) + tx_desc = &tx_q->dma_entx[entry].basic; + else + tx_desc = tx_q->dma_tx + entry; + + dma_addr = xsk_buff_raw_get_dma(pool, xdp_desc.addr); + xsk_buff_raw_dma_sync_for_device(pool, dma_addr, xdp_desc.len); + + tx_q->tx_skbuff_dma[entry].buf_type = stmmac_txbuf_t_xsk_tx; + + /* to return xdp buffer to xsk pool, we simple call + * xsk_tx_completed(), so we don't need to fill up + * 'buf' and 'xdpf'. + */ + tx_q->tx_skbuff_dma[entry].buf = 0; + tx_q->xdpf[entry] = null; + + tx_q->tx_skbuff_dma[entry].map_as_page = false; + tx_q->tx_skbuff_dma[entry].len = xdp_desc.len; + tx_q->tx_skbuff_dma[entry].last_segment = true; + tx_q->tx_skbuff_dma[entry].is_jumbo = false; + + stmmac_set_desc_addr(priv, tx_desc, dma_addr); + + tx_q->tx_count_frames++; + + if (!priv->tx_coal_frames[queue]) + set_ic = false; + else if (tx_q->tx_count_frames % priv->tx_coal_frames[queue] == 0) + set_ic = true; + else + set_ic = false; + + if (set_ic) { + tx_q->tx_count_frames = 0; + stmmac_set_tx_ic(priv, tx_desc); + priv->xstats.tx_set_ic_bit++; + } + + stmmac_prepare_tx_desc(priv, tx_desc, 1, xdp_desc.len, + true, priv->mode, true, true, + xdp_desc.len); + + stmmac_enable_dma_transmission(priv, priv->ioaddr); + + tx_q->cur_tx = stmmac_get_entry(tx_q->cur_tx, priv->dma_tx_size); + entry = tx_q->cur_tx; + } + + if (tx_desc) { + stmmac_flush_tx_descriptors(priv, queue); + xsk_tx_release(pool); + } + + /* return true if all of the 3 conditions are met + * a) tx budget is still available + * b) work_done = true when xsk tx desc peek is empty (no more + * pending xsk tx for transmission) + */ + return !!budget && work_done; +} + - unsigned int entry, count = 0; + unsigned int entry, xmits = 0, count = 0; + tx_q->xsk_frames_done = 0; + - while ((entry != tx_q->cur_tx) && (count < budget)) { + + /* try to clean all tx complete frame in 1 shot */ + while ((entry != tx_q->cur_tx) && count < priv->dma_tx_size) { + if (tx_q->tx_skbuff_dma[entry].buf_type == stmmac_txbuf_t_xsk_tx) + tx_q->xsk_frames_done++; + + if (tx_q->xsk_pool) { + bool work_done; + + if (tx_q->xsk_frames_done) + xsk_tx_completed(tx_q->xsk_pool, tx_q->xsk_frames_done); + + if (xsk_uses_need_wakeup(tx_q->xsk_pool)) + xsk_set_tx_need_wakeup(tx_q->xsk_pool); + + /* for xsk tx, we try to send as many as possible. + * if xsk work done (xsk tx desc empty and budget still + * available), return "budget - 1" to reenable tx irq. + * else, return "budget" to make napi continue polling. + */ + work_done = stmmac_xdp_xmit_zc(priv, queue, + stmmac_xsk_tx_budget_max); + if (work_done) + xmits = budget - 1; + else + xmits = budget; + } + - return count; + /* combine decisions from tx clean and xsk tx */ + return max(count, xmits); + struct stmmac_rx_queue *rx_q = &priv->rx_queue[chan]; + struct stmmac_tx_queue *tx_q = &priv->tx_queue[chan]; + struct napi_struct *rx_napi; + struct napi_struct *tx_napi; + rx_napi = rx_q->xsk_pool ? &ch->rxtx_napi : &ch->rx_napi; + tx_napi = tx_q->xsk_pool ? &ch->rxtx_napi : &ch->tx_napi; + - if (napi_schedule_prep(&ch->rx_napi)) { + if (napi_schedule_prep(rx_napi)) { - __napi_schedule(&ch->rx_napi); + __napi_schedule(rx_napi); - if (napi_schedule_prep(&ch->tx_napi)) { + if (napi_schedule_prep(tx_napi)) { - __napi_schedule(&ch->tx_napi); + __napi_schedule(tx_napi); + struct napi_struct *napi; + napi = tx_q->xsk_pool ? &ch->rxtx_napi : &ch->tx_napi; - if (likely(napi_schedule_prep(&ch->tx_napi))) { + if (likely(napi_schedule_prep(napi))) { - __napi_schedule(&ch->tx_napi); + __napi_schedule(napi); - skb = __napi_alloc_skb(&ch->rx_napi, + skb = __napi_alloc_skb(&ch->rxtx_napi, - napi_gro_receive(&ch->rx_napi, skb); + napi_gro_receive(&ch->rxtx_napi, skb); - struct stmmac_rx_queue *rx_q; - rx_q = &priv->rx_queue[chan]; - - work_done = rx_q->xsk_pool ? - stmmac_rx_zc(priv, budget, chan) : - stmmac_rx(priv, budget, chan); + work_done = stmmac_rx(priv, budget, chan); - work_done = stmmac_tx_clean(priv, priv->dma_tx_size, chan); + work_done = stmmac_tx_clean(priv, budget, chan); +static int stmmac_napi_poll_rxtx(struct napi_struct *napi, int budget) +{ + struct stmmac_channel *ch = + container_of(napi, struct stmmac_channel, rxtx_napi); + struct stmmac_priv *priv = ch->priv_data; + int rx_done, tx_done; + u32 chan = ch->index; + + priv->xstats.napi_poll++; + + tx_done = stmmac_tx_clean(priv, budget, chan); + tx_done = min(tx_done, budget); + + rx_done = stmmac_rx_zc(priv, budget, chan); + + /* if either tx or rx work is not complete, return budget + * and keep pooling + */ + if (tx_done >= budget || rx_done >= budget) + return budget; + + /* all work done, exit the polling mode */ + if (napi_complete_done(napi, rx_done)) { + unsigned long flags; + + spin_lock_irqsave(&ch->lock, flags); + /* both rx and tx work done are compelte, + * so enable both rx & tx irqs. + */ + stmmac_enable_dma_irq(priv, priv->ioaddr, chan, 1, 1); + spin_unlock_irqrestore(&ch->lock, flags); + } + + return min(rx_done, budget - 1); +} + +void stmmac_disable_tx_queue(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_channel *ch = &priv->channel[queue]; + unsigned long flags; + + spin_lock_irqsave(&ch->lock, flags); + stmmac_disable_dma_irq(priv, priv->ioaddr, queue, 0, 1); + spin_unlock_irqrestore(&ch->lock, flags); + + stmmac_stop_tx_dma(priv, queue); + __free_dma_tx_desc_resources(priv, queue); +} + +void stmmac_enable_tx_queue(struct stmmac_priv *priv, u32 queue) +{ + struct stmmac_tx_queue *tx_q = &priv->tx_queue[queue]; + struct stmmac_channel *ch = &priv->channel[queue]; + unsigned long flags; + int ret; + + ret = __alloc_dma_tx_desc_resources(priv, queue); + if (ret) { + netdev_err(priv->dev, "failed to alloc tx desc. "); + return; + } + + ret = __init_dma_tx_desc_rings(priv, queue); + if (ret) { + __free_dma_tx_desc_resources(priv, queue); + netdev_err(priv->dev, "failed to init tx desc. "); + return; + } + + stmmac_clear_tx_descriptors(priv, queue); + + stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg, + tx_q->dma_tx_phy, tx_q->queue_index); + + if (tx_q->tbs & stmmac_tbs_avail) + stmmac_enable_tbs(priv, priv->ioaddr, 1, tx_q->queue_index); + + tx_q->tx_tail_addr = tx_q->dma_tx_phy; + stmmac_set_tx_tail_ptr(priv, priv->ioaddr, + tx_q->tx_tail_addr, tx_q->queue_index); + + stmmac_start_tx_dma(priv, queue); + + spin_lock_irqsave(&ch->lock, flags); + stmmac_enable_dma_irq(priv, priv->ioaddr, queue, 0, 1); + spin_unlock_irqrestore(&ch->lock, flags); +} + + struct stmmac_tx_queue *tx_q; - if (queue >= priv->plat->rx_queues_to_use) + if (queue >= priv->plat->rx_queues_to_use || + queue >= priv->plat->tx_queues_to_use) + tx_q = &priv->tx_queue[queue]; - if (!rx_q->xsk_pool) + if (!rx_q->xsk_pool && !tx_q->xsk_pool) - if (flags & xdp_wakeup_rx && - !napi_if_scheduled_mark_missed(&ch->rx_napi)) { + if (!napi_if_scheduled_mark_missed(&ch->rxtx_napi)) { - if (likely(napi_schedule_prep(&ch->rx_napi))) - __napi_schedule(&ch->rx_napi); + if (likely(napi_schedule_prep(&ch->rxtx_napi))) + __napi_schedule(&ch->rxtx_napi); + if (queue < priv->plat->rx_queues_to_use && + queue < priv->plat->tx_queues_to_use) { + netif_napi_add(dev, &ch->rxtx_napi, + stmmac_napi_poll_rxtx, + napi_poll_weight); + } + if (queue < priv->plat->rx_queues_to_use && + queue < priv->plat->tx_queues_to_use) { + netif_napi_del(&ch->rxtx_napi); + } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c - if (queue >= priv->plat->rx_queues_to_use) + if (queue >= priv->plat->rx_queues_to_use || + queue >= priv->plat->tx_queues_to_use) + stmmac_disable_tx_queue(priv, queue); + napi_disable(&ch->tx_napi); - napi_enable(&ch->rx_napi); + napi_enable(&ch->rxtx_napi); + stmmac_enable_tx_queue(priv, queue); - if (queue >= priv->plat->rx_queues_to_use) + if (queue >= priv->plat->rx_queues_to_use || + queue >= priv->plat->tx_queues_to_use) + stmmac_disable_tx_queue(priv, queue); - napi_disable(&ch->rx_napi); + napi_disable(&ch->rxtx_napi); + napi_enable(&ch->tx_napi); + stmmac_enable_tx_queue(priv, queue);
|
Networking
|
132c32ee5bc09b1d2fa518f3b38a01f4b859b6df
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add hardware supported cross-timestamp
|
cross timestamping is supported on integrated ethernet controller in intel soc such as ehl and tgl with always running timer.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add hardware supported cross-timestamp
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 9
| 193
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h + /* numbers of auxiliary snapshot inputs */ + unsigned int aux_snapshot_n; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +#include "stmmac_ptp.h" +static void get_arttime(struct mii_bus *mii, int intel_adhoc_addr, + u64 *art_time) +{ + u64 ns; + + ns = mdiobus_read(mii, intel_adhoc_addr, pmc_art_value3); + ns <<= gmac4_art_time_shift; + ns |= mdiobus_read(mii, intel_adhoc_addr, pmc_art_value2); + ns <<= gmac4_art_time_shift; + ns |= mdiobus_read(mii, intel_adhoc_addr, pmc_art_value1); + ns <<= gmac4_art_time_shift; + ns |= mdiobus_read(mii, intel_adhoc_addr, pmc_art_value0); + + *art_time = ns; +} + +static int intel_crosststamp(ktime_t *device, + struct system_counterval_t *system, + void *ctx) +{ + struct intel_priv_data *intel_priv; + + struct stmmac_priv *priv = (struct stmmac_priv *)ctx; + void __iomem *ptpaddr = priv->ptpaddr; + void __iomem *ioaddr = priv->hw->pcsr; + unsigned long flags; + u64 art_time = 0; + u64 ptp_time = 0; + u32 num_snapshot; + u32 gpio_value; + u32 acr_value; + int ret; + u32 v; + int i; + + if (!boot_cpu_has(x86_feature_art)) + return -eopnotsupp; + + intel_priv = priv->plat->bsp_priv; + + /* enable internal snapshot trigger */ + acr_value = readl(ptpaddr + ptp_acr); + acr_value &= ~ptp_acr_mask; + switch (priv->plat->int_snapshot_num) { + case aux_snapshot0: + acr_value |= ptp_acr_atsen0; + break; + case aux_snapshot1: + acr_value |= ptp_acr_atsen1; + break; + case aux_snapshot2: + acr_value |= ptp_acr_atsen2; + break; + case aux_snapshot3: + acr_value |= ptp_acr_atsen3; + break; + default: + return -einval; + } + writel(acr_value, ptpaddr + ptp_acr); + + /* clear fifo */ + acr_value = readl(ptpaddr + ptp_acr); + acr_value |= ptp_acr_atsfc; + writel(acr_value, ptpaddr + ptp_acr); + + /* trigger internal snapshot signal + * create a rising edge by just toggle the gpo1 to low + * and back to high. + */ + gpio_value = readl(ioaddr + gmac_gpio_status); + gpio_value &= ~gmac_gpo1; + writel(gpio_value, ioaddr + gmac_gpio_status); + gpio_value |= gmac_gpo1; + writel(gpio_value, ioaddr + gmac_gpio_status); + + /* poll for time sync operation done */ + ret = readl_poll_timeout(priv->ioaddr + gmac_int_status, v, + (v & gmac_int_tsie), 100, 10000); + + if (ret == -etimedout) { + pr_err("%s: wait for time sync operation timeout ", __func__); + return ret; + } + + num_snapshot = (readl(ioaddr + gmac_timestamp_status) & + gmac_timestamp_atsns_mask) >> + gmac_timestamp_atsns_shift; + + /* repeat until the timestamps are from the fifo last segment */ + for (i = 0; i < num_snapshot; i++) { + spin_lock_irqsave(&priv->ptp_lock, flags); + stmmac_get_ptptime(priv, ptpaddr, &ptp_time); + *device = ns_to_ktime(ptp_time); + spin_unlock_irqrestore(&priv->ptp_lock, flags); + get_arttime(priv->mii, intel_priv->mdio_adhoc_addr, &art_time); + *system = convert_art_to_tsc(art_time); + } + + return 0; +} + + plat->int_snapshot_num = aux_snapshot1; + + plat->has_crossts = true; + plat->crosststamp = intel_crosststamp; + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +#define gmac_timestamp_status 0x00000b20 +#define gmac_int_tsie bit(12) +#define gmac_hw_feat_auxsnapnum genmask(30, 28) +/* mac timestamp status */ +#define gmac_timestamp_auxtstrig bit(2) +#define gmac_timestamp_atsns_mask genmask(29, 25) +#define gmac_timestamp_atsns_shift 25 + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c + /* number of auxiliary snapshot inputs */ + dma_cap->aux_snapshot_n = (hw_cap & gmac_hw_feat_auxsnapnum) >> 28; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h + void (*get_ptptime)(void __iomem *ioaddr, u64 *ptp_time); +#define stmmac_get_ptptime(__priv, __args...) \ + stmmac_do_void_callback(__priv, ptp, get_ptptime, __args) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +static void get_ptptime(void __iomem *ptpaddr, u64 *ptp_time) +{ + u64 ns; + + ns = readl(ptpaddr + ptp_atnr); + ns += readl(ptpaddr + ptp_atsr) * nsec_per_sec; + + *ptp_time = ns; +} + + .get_ptptime = get_ptptime, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +#include "dwmac4.h" +/** + * stmmac_get_syncdevicetime + * @device: current device time + * @system: system counter value read synchronously with device time + * @ctx: context provided by timekeeping code + * description: read device and system clock simultaneously and return the + * corrected clock values in ns. + **/ +static int stmmac_get_syncdevicetime(ktime_t *device, + struct system_counterval_t *system, + void *ctx) +{ + struct stmmac_priv *priv = (struct stmmac_priv *)ctx; + + if (priv->plat->crosststamp) + return priv->plat->crosststamp(device, system, ctx); + else + return -eopnotsupp; +} + +static int stmmac_getcrosststamp(struct ptp_clock_info *ptp, + struct system_device_crosststamp *xtstamp) +{ + struct stmmac_priv *priv = + container_of(ptp, struct stmmac_priv, ptp_clock_ops); + + return get_device_system_crosststamp(stmmac_get_syncdevicetime, + priv, null, xtstamp); +} + + .getcrosststamp = stmmac_getcrosststamp, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +#define ptp_acr 0x40 /* auxiliary control reg */ +#define ptp_atnr 0x48 /* auxiliary timestamp - nanoseconds reg */ +#define ptp_atsr 0x4c /* auxiliary timestamp - seconds reg */ +/* auxiliary control defines */ +#define ptp_acr_atsfc bit(0) /* auxiliary snapshot fifo clear */ +#define ptp_acr_atsen0 bit(4) /* auxiliary snapshot 0 enable */ +#define ptp_acr_atsen1 bit(5) /* auxiliary snapshot 1 enable */ +#define ptp_acr_atsen2 bit(6) /* auxiliary snapshot 2 enable */ +#define ptp_acr_atsen3 bit(7) /* auxiliary snapshot 3 enable */ +#define ptp_acr_mask genmask(7, 4) /* aux snapshot mask */ +#define pmc_art_value0 0x01 /* pmc_art[15:0] timer value */ +#define pmc_art_value1 0x02 /* pmc_art[31:16] timer value */ +#define pmc_art_value2 0x03 /* pmc_art[47:32] timer value */ +#define pmc_art_value3 0x04 /* pmc_art[63:48] timer value */ +#define gmac4_art_time_shift 16 /* art time 16-bits shift */ + +enum aux_snapshot { + aux_snapshot0 = 0x10, + aux_snapshot1 = 0x20, + aux_snapshot2 = 0x40, + aux_snapshot3 = 0x80, +}; + diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h + int (*crosststamp)(ktime_t *device, struct system_counterval_t *system, + void *ctx); + bool has_crossts; + int int_snapshot_num;
|
Networking
|
341f67e424e572bfc034daa534c6fa667533e6a4
|
tan tee min
|
include
|
linux
|
ethernet, stmicro, stmmac
|
net: stmmac: add support for external trigger timestamping
|
the synopsis mac controller supports auxiliary snapshot feature that allows user to store a snapshot of the system time based on an external event.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for external trigger timestamping
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 8
| 101
| 1
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c + /* both internal crosstimestamping and external triggered event + * timestamping cannot be run concurrently. + */ + if (priv->plat->ext_snapshot_en) + return -ebusy; + + mutex_lock(&priv->aux_ts_lock); + /* release the mutex */ + mutex_unlock(&priv->aux_ts_lock); + plat->ext_snapshot_num = aux_snapshot0; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h +struct stmmac_priv; + + void (*timestamp_interrupt)(struct stmmac_priv *priv); +#define stmmac_timestamp_interrupt(__priv, __args...) \ + stmmac_do_void_callback(__priv, ptp, timestamp_interrupt, __args) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h + /* protects auxiliary snapshot registers from concurrent access. */ + struct mutex aux_ts_lock; + diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +#include <linux/ptp_clock_kernel.h> +#include "dwmac4.h" +#include "stmmac.h" +static void timestamp_interrupt(struct stmmac_priv *priv) +{ + u32 num_snapshot, ts_status, tsync_int; + struct ptp_clock_event event; + unsigned long flags; + u64 ptp_time; + int i; + + tsync_int = readl(priv->ioaddr + gmac_int_status) & gmac_int_tsie; + + if (!tsync_int) + return; + + /* read timestamp status to clear interrupt from either external + * timestamp or start/end of pps. + */ + ts_status = readl(priv->ioaddr + gmac_timestamp_status); + + if (!priv->plat->ext_snapshot_en) + return; + + num_snapshot = (ts_status & gmac_timestamp_atsns_mask) >> + gmac_timestamp_atsns_shift; + + for (i = 0; i < num_snapshot; i++) { + spin_lock_irqsave(&priv->ptp_lock, flags); + get_ptptime(priv->ptpaddr, &ptp_time); + spin_unlock_irqrestore(&priv->ptp_lock, flags); + event.type = ptp_clock_extts; + event.index = 0; + event.timestamp = ptp_time; + ptp_clock_event(priv->ptp_clock, &event); + } +} + + .timestamp_interrupt = timestamp_interrupt, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + + stmmac_timestamp_interrupt(priv, priv); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c + void __iomem *ptpaddr = priv->ptpaddr; + void __iomem *ioaddr = priv->hw->pcsr; + u32 intr_value, acr_value; + case ptp_clk_req_extts: + priv->plat->ext_snapshot_en = on; + mutex_lock(&priv->aux_ts_lock); + acr_value = readl(ptpaddr + ptp_acr); + acr_value &= ~ptp_acr_mask; + if (on) { + /* enable external snapshot trigger */ + acr_value |= priv->plat->ext_snapshot_num; + acr_value |= ptp_acr_atsfc; + netdev_dbg(priv->dev, "auxiliary snapshot %d enabled. ", + priv->plat->ext_snapshot_num >> + ptp_acr_atsen_shift); + /* enable timestamp interrupt */ + intr_value = readl(ioaddr + gmac_int_en); + intr_value |= gmac_int_tsie; + writel(intr_value, ioaddr + gmac_int_en); + + } else { + netdev_dbg(priv->dev, "auxiliary snapshot %d disabled. ", + priv->plat->ext_snapshot_num >> + ptp_acr_atsen_shift); + /* disable timestamp interrupt */ + intr_value = readl(ioaddr + gmac_int_en); + intr_value &= ~gmac_int_tsie; + writel(intr_value, ioaddr + gmac_int_en); + } + writel(acr_value, ptpaddr + ptp_acr); + mutex_unlock(&priv->aux_ts_lock); + ret = 0; + break; + - .n_ext_ts = 0, + .n_ext_ts = 0, /* will be overwritten in stmmac_ptp_register */ + stmmac_ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; + mutex_init(&priv->aux_ts_lock); + + mutex_destroy(&priv->aux_ts_lock); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +#define ptp_acr_atsen_shift 5 /* auxiliary snapshot shift */ diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h + int ext_snapshot_num; + bool ext_snapshot_en;
|
Networking
|
f4da56529da602010979e8497d1f02eaf5df8883
|
tan tee min
|
include
|
linux
|
ethernet, stmicro, stmmac
|
net: stmmac: restructure tc implementation for rx vlan priority steering
|
the current tc_add_flow() and tc_del_flow() use hardware l3 & l4 filters as offloading. the number of l3/l4 filters is read from l3l4fnum field from mac_hw_feature1 register and is used to alloc priv->tc_entries[].
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add vlan priority based rx steering
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 22
| 2
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +static int tc_add_flow_cls(struct stmmac_priv *priv, + struct flow_cls_offload *cls) +{ + int ret; + + ret = tc_add_flow(priv, cls); + + return ret; +} + +static int tc_del_flow_cls(struct stmmac_priv *priv, + struct flow_cls_offload *cls) +{ + int ret; + + ret = tc_del_flow(priv, cls); + + return ret; +} + - ret = tc_add_flow(priv, cls); + ret = tc_add_flow_cls(priv, cls); - ret = tc_del_flow(priv, cls); + ret = tc_del_flow_cls(priv, cls);
|
Networking
|
bd0f670e793137fac1f8cc95f1feac99cc081cba
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add rx frame steering based on vlan priority in tc flower
|
we extend tc flower to support configuration of vlan priority-based rx frame steering hardware offloading.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add vlan priority based rx steering
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 63
| 2
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +#define vlan_prio_full_mask (0x07) + +static int tc_add_vlan_flow(struct stmmac_priv *priv, + struct flow_cls_offload *cls) +{ + struct flow_rule *rule = flow_cls_offload_flow_rule(cls); + struct flow_dissector *dissector = rule->match.dissector; + int tc = tc_classid_to_hwtc(priv->dev, cls->classid); + struct flow_match_vlan match; + + /* nothing to do here */ + if (!dissector_uses_key(dissector, flow_dissector_key_vlan)) + return -einval; + + if (tc < 0) { + netdev_err(priv->dev, "invalid traffic class "); + return -einval; + } + + flow_rule_match_vlan(rule, &match); + + if (match.mask->vlan_priority) { + u32 prio; + + if (match.mask->vlan_priority != vlan_prio_full_mask) { + netdev_err(priv->dev, "only full mask is supported for vlan priority"); + return -einval; + } + + prio = bit(match.key->vlan_priority); + stmmac_rx_queue_prio(priv, priv->hw, prio, tc); + } + + return 0; +} + +static int tc_del_vlan_flow(struct stmmac_priv *priv, + struct flow_cls_offload *cls) +{ + struct flow_rule *rule = flow_cls_offload_flow_rule(cls); + struct flow_dissector *dissector = rule->match.dissector; + int tc = tc_classid_to_hwtc(priv->dev, cls->classid); + + /* nothing to do here */ + if (!dissector_uses_key(dissector, flow_dissector_key_vlan)) + return -einval; + + if (tc < 0) { + netdev_err(priv->dev, "invalid traffic class "); + return -einval; + } + + stmmac_rx_queue_prio(priv, priv->hw, 0, tc); + + return 0; +} + + if (!ret) + return ret; - return ret; + return tc_add_vlan_flow(priv, cls); + if (!ret) + return ret; - return ret; + return tc_del_vlan_flow(priv, cls);
|
Networking
|
0e039f5cf86ce2fcb62077a163e7ff3d7b7b7cf3
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: add per-queue tx & rx coalesce ethtool support
|
extending the driver to support per-queue rx and tx coalesce settings in order to support below commands:
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add per-queue tx & rx coalesce ethtool support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 7
| 143
| 49
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c - u32 number_chan) + u32 queue) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c -static void dwmac4_rx_watchdog(void __iomem *ioaddr, u32 riwt, u32 number_chan) +static void dwmac4_rx_watchdog(void __iomem *ioaddr, u32 riwt, u32 queue) - u32 chan; - - for (chan = 0; chan < number_chan; chan++) - writel(riwt, ioaddr + dma_chan_rx_watchdog(chan)); + writel(riwt, ioaddr + dma_chan_rx_watchdog(queue)); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c -static void dwxgmac2_rx_watchdog(void __iomem *ioaddr, u32 riwt, u32 nchan) +static void dwxgmac2_rx_watchdog(void __iomem *ioaddr, u32 riwt, u32 queue) - u32 i; - - for (i = 0; i < nchan; i++) - writel(riwt & xgmac_rwt, ioaddr + xgmac_dma_ch_rx_watchdog(i)); + writel(riwt & xgmac_rwt, ioaddr + xgmac_dma_ch_rx_watchdog(queue)); diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h - void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt, u32 number_chan); + void (*rx_watchdog)(void __iomem *ioaddr, u32 riwt, u32 queue); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h - u32 tx_coal_frames; - u32 tx_coal_timer; - u32 rx_coal_frames; + u32 tx_coal_frames[mtl_max_tx_queues]; + u32 tx_coal_timer[mtl_max_tx_queues]; + u32 rx_coal_frames[mtl_max_tx_queues]; - u32 rx_riwt; + u32 rx_riwt[mtl_max_tx_queues]; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c -static int stmmac_get_coalesce(struct net_device *dev, - struct ethtool_coalesce *ec) +static int __stmmac_get_coalesce(struct net_device *dev, + struct ethtool_coalesce *ec, + int queue) + u32 max_cnt; + u32 rx_cnt; + u32 tx_cnt; - ec->tx_coalesce_usecs = priv->tx_coal_timer; - ec->tx_max_coalesced_frames = priv->tx_coal_frames; + rx_cnt = priv->plat->rx_queues_to_use; + tx_cnt = priv->plat->tx_queues_to_use; + max_cnt = max(rx_cnt, tx_cnt); - if (priv->use_riwt) { - ec->rx_max_coalesced_frames = priv->rx_coal_frames; - ec->rx_coalesce_usecs = stmmac_riwt2usec(priv->rx_riwt, priv); + if (queue < 0) + queue = 0; + else if (queue >= max_cnt) + return -einval; + + if (queue < tx_cnt) { + ec->tx_coalesce_usecs = priv->tx_coal_timer[queue]; + ec->tx_max_coalesced_frames = priv->tx_coal_frames[queue]; + } else { + ec->tx_coalesce_usecs = 0; + ec->tx_max_coalesced_frames = 0; + } + + if (priv->use_riwt && queue < rx_cnt) { + ec->rx_max_coalesced_frames = priv->rx_coal_frames[queue]; + ec->rx_coalesce_usecs = stmmac_riwt2usec(priv->rx_riwt[queue], + priv); + } else { + ec->rx_max_coalesced_frames = 0; + ec->rx_coalesce_usecs = 0; -static int stmmac_set_coalesce(struct net_device *dev, +static int stmmac_get_coalesce(struct net_device *dev, +{ + return __stmmac_get_coalesce(dev, ec, -1); +} + +static int stmmac_get_per_queue_coalesce(struct net_device *dev, u32 queue, + struct ethtool_coalesce *ec) +{ + return __stmmac_get_coalesce(dev, ec, queue); +} + +static int __stmmac_set_coalesce(struct net_device *dev, + struct ethtool_coalesce *ec, + int queue) - u32 rx_cnt = priv->plat->rx_queues_to_use; + bool all_queues = false; + u32 max_cnt; + u32 rx_cnt; + u32 tx_cnt; + + rx_cnt = priv->plat->rx_queues_to_use; + tx_cnt = priv->plat->tx_queues_to_use; + max_cnt = max(rx_cnt, tx_cnt); + + if (queue < 0) + all_queues = true; + else if (queue >= max_cnt) + return -einval; - priv->rx_riwt = rx_riwt; - stmmac_rx_watchdog(priv, priv->ioaddr, priv->rx_riwt, rx_cnt); + if (all_queues) { + int i; + + for (i = 0; i < rx_cnt; i++) { + priv->rx_riwt[i] = rx_riwt; + stmmac_rx_watchdog(priv, priv->ioaddr, + rx_riwt, i); + priv->rx_coal_frames[i] = + ec->rx_max_coalesced_frames; + } + } else if (queue < rx_cnt) { + priv->rx_riwt[queue] = rx_riwt; + stmmac_rx_watchdog(priv, priv->ioaddr, + rx_riwt, queue); + priv->rx_coal_frames[queue] = + ec->rx_max_coalesced_frames; + } - /* only copy relevant parameters, ignore all others. */ - priv->tx_coal_frames = ec->tx_max_coalesced_frames; - priv->tx_coal_timer = ec->tx_coalesce_usecs; - priv->rx_coal_frames = ec->rx_max_coalesced_frames; + if (all_queues) { + int i; + + for (i = 0; i < tx_cnt; i++) { + priv->tx_coal_frames[i] = + ec->tx_max_coalesced_frames; + priv->tx_coal_timer[i] = + ec->tx_coalesce_usecs; + } + } else if (queue < tx_cnt) { + priv->tx_coal_frames[queue] = + ec->tx_max_coalesced_frames; + priv->tx_coal_timer[queue] = + ec->tx_coalesce_usecs; + } + +static int stmmac_set_coalesce(struct net_device *dev, + struct ethtool_coalesce *ec) +{ + return __stmmac_set_coalesce(dev, ec, -1); +} + +static int stmmac_set_per_queue_coalesce(struct net_device *dev, u32 queue, + struct ethtool_coalesce *ec) +{ + return __stmmac_set_coalesce(dev, ec, queue); +} + + .get_per_queue_coalesce = stmmac_get_per_queue_coalesce, + .set_per_queue_coalesce = stmmac_set_per_queue_coalesce, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c - hrtimer_start(&tx_q->txtimer, stmmac_coal_timer(priv->tx_coal_timer), + hrtimer_start(&tx_q->txtimer, + stmmac_coal_timer(priv->tx_coal_timer[queue]), - hrtimer_start(&tx_q->txtimer, stmmac_coal_timer(priv->tx_coal_timer), + hrtimer_start(&tx_q->txtimer, + stmmac_coal_timer(priv->tx_coal_timer[queue]), + u32 rx_channel_count = priv->plat->rx_queues_to_use; - priv->tx_coal_frames = stmmac_tx_frames; - priv->tx_coal_timer = stmmac_coal_tx_timer; - priv->rx_coal_frames = stmmac_rx_frames; - + priv->tx_coal_frames[chan] = stmmac_tx_frames; + priv->tx_coal_timer[chan] = stmmac_coal_tx_timer; + + + for (chan = 0; chan < rx_channel_count; chan++) + priv->rx_coal_frames[chan] = stmmac_rx_frames; - if (!priv->rx_riwt) - priv->rx_riwt = def_dma_riwt; + u32 queue; + + for (queue = 0; queue < rx_cnt; queue++) { + if (!priv->rx_riwt[queue]) + priv->rx_riwt[queue] = def_dma_riwt; - ret = stmmac_rx_watchdog(priv, priv->ioaddr, priv->rx_riwt, rx_cnt); + stmmac_rx_watchdog(priv, priv->ioaddr, + priv->rx_riwt[queue], queue); + } - else if (!priv->tx_coal_frames) + else if (!priv->tx_coal_frames[queue]) - else if (tx_packets > priv->tx_coal_frames) + else if (tx_packets > priv->tx_coal_frames[queue]) - else if ((tx_q->tx_count_frames % priv->tx_coal_frames) < tx_packets) + else if ((tx_q->tx_count_frames % + priv->tx_coal_frames[queue]) < tx_packets) - else if (!priv->tx_coal_frames) + else if (!priv->tx_coal_frames[queue]) - else if (tx_packets > priv->tx_coal_frames) + else if (tx_packets > priv->tx_coal_frames[queue]) - else if ((tx_q->tx_count_frames % priv->tx_coal_frames) < tx_packets) + else if ((tx_q->tx_count_frames % + priv->tx_coal_frames[queue]) < tx_packets) - rx_q->rx_count_frames += priv->rx_coal_frames; - if (rx_q->rx_count_frames > priv->rx_coal_frames) + rx_q->rx_count_frames += priv->rx_coal_frames[queue]; + if (rx_q->rx_count_frames > priv->rx_coal_frames[queue]) - use_rx_wd = !priv->rx_coal_frames; + use_rx_wd = !priv->rx_coal_frames[queue];
|
Networking
|
db2f2842e6f56027b1a29c7b16dc40482f41563b
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: enable mtl ecc error address status over-ride by default
|
turn on the meeao field of mtl_ecc_control_register by default.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
enable mtl ecc error address status over-ride by default
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 2
| 2
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c + value |= meeao; /* mtl ecc error addr status override */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +#define meeao bit(8)
|
Networking
|
b494ba5a3cf822fa99fb941cd1c293da21f4f927
|
voon weifeng
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
stmmac: intel: add pse and pch ptp clock source selection
|
intel mgbe variant implemented in ehl and tgl can be set to select different clock frequency based on gpo bits in mac_gpio_status register.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add pse and pch ptp clock source selection
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ', 'intel']
|
['h', 'c']
| 4
| 57
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +/* selection for ptp clock freq belongs to pse & pch gbe */ +#define pse_ptp_clk_freq_mask (gmac_gpo0 | gmac_gpo3) +#define pse_ptp_clk_freq_19_2mhz (gmac_gpo0) +#define pse_ptp_clk_freq_200mhz (gmac_gpo0 | gmac_gpo3) +#define pse_ptp_clk_freq_256mhz (0) +#define pch_ptp_clk_freq_mask (gmac_gpo0) +#define pch_ptp_clk_freq_19_2mhz (gmac_gpo0) +#define pch_ptp_clk_freq_200mhz (0) + + bool is_pse; +/* program ptp clock frequency for different variant of + * intel mgbe that has slightly different gpo mapping + */ +static void intel_mgbe_ptp_clk_freq_config(void *npriv) +{ + struct stmmac_priv *priv = (struct stmmac_priv *)npriv; + struct intel_priv_data *intel_priv; + u32 gpio_value; + + intel_priv = (struct intel_priv_data *)priv->plat->bsp_priv; + + gpio_value = readl(priv->ioaddr + gmac_gpio_status); + + if (intel_priv->is_pse) { + /* for pse gbe, use 200mhz */ + gpio_value &= ~pse_ptp_clk_freq_mask; + gpio_value |= pse_ptp_clk_freq_200mhz; + } else { + /* for pch gbe, use 200mhz */ + gpio_value &= ~pch_ptp_clk_freq_mask; + gpio_value |= pch_ptp_clk_freq_200mhz; + } + + writel(gpio_value, priv->ioaddr + gmac_gpio_status); +} + + plat->ptp_clk_freq_config = intel_mgbe_ptp_clk_freq_config; + + struct intel_priv_data *intel_priv = plat->bsp_priv; + + intel_priv->is_pse = true; + + struct intel_priv_data *intel_priv = plat->bsp_priv; + + intel_priv->is_pse = true; + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +#define gmac_gpio_status 0x0000020c +/* gmac gpio status reg */ +#define gmac_gpo0 bit(16) +#define gmac_gpo1 bit(17) +#define gmac_gpo2 bit(18) +#define gmac_gpo3 bit(19) + diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c + if (priv->plat->ptp_clk_freq_config) + priv->plat->ptp_clk_freq_config(priv); + diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h + void (*ptp_clk_freq_config)(void *priv);
|
Networking
|
76da35dc99afb460b9c335182ba6a3e7ff924186
|
wong vee khee
|
include
|
linux
|
ethernet, stmicro, stmmac
|
net: pcs: rearrange c73 functions to prepare for c37 support later
|
the current implementation for xpcs is validated for c73, so we rename them to have _c73 suffix and introduce a set of functions to use an_mode flag to switch between c73 and c37 an later.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add c37 an sgmii support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 2
| 70
| 28
|
--- diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c + int an_mode; + .an_mode = dw_an_c73, + .an_mode = dw_an_c73, + .an_mode = dw_an_c73, -static int xpcs_soft_reset(struct mdio_xpcs_args *xpcs, int dev) +static int xpcs_soft_reset(struct mdio_xpcs_args *xpcs) - int ret; + int ret, dev; + + switch (xpcs->an_mode) { + case dw_an_c73: + dev = mdio_mmd_pcs; + break; + default: + return -1; + } -static int xpcs_read_fault(struct mdio_xpcs_args *xpcs, - struct phylink_link_state *state) +static int xpcs_read_fault_c73(struct mdio_xpcs_args *xpcs, + struct phylink_link_state *state) -static int xpcs_read_link(struct mdio_xpcs_args *xpcs, bool an) +static int xpcs_read_link_c73(struct mdio_xpcs_args *xpcs, bool an) -static int xpcs_config_aneg_c73(struct mdio_xpcs_args *xpcs) +static int _xpcs_config_aneg_c73(struct mdio_xpcs_args *xpcs) -static int xpcs_config_aneg(struct mdio_xpcs_args *xpcs) +static int xpcs_config_aneg_c73(struct mdio_xpcs_args *xpcs) - ret = xpcs_config_aneg_c73(xpcs); + ret = _xpcs_config_aneg_c73(xpcs); -static int xpcs_aneg_done(struct mdio_xpcs_args *xpcs, - struct phylink_link_state *state) +static int xpcs_aneg_done_c73(struct mdio_xpcs_args *xpcs, + struct phylink_link_state *state) - xpcs_config_aneg(xpcs); + xpcs_config_aneg_c73(xpcs); -static int xpcs_read_lpa(struct mdio_xpcs_args *xpcs, - struct phylink_link_state *state) +static int xpcs_read_lpa_c73(struct mdio_xpcs_args *xpcs, + struct phylink_link_state *state) -static void xpcs_resolve_lpa(struct mdio_xpcs_args *xpcs, - struct phylink_link_state *state) +static void xpcs_resolve_lpa_c73(struct mdio_xpcs_args *xpcs, + struct phylink_link_state *state) - if (state->an_enabled) { - ret = xpcs_config_aneg(xpcs); - if (ret) - return ret; + switch (xpcs->an_mode) { + case dw_an_c73: + if (state->an_enabled) { + ret = xpcs_config_aneg_c73(xpcs); + if (ret) + return ret; + } + break; + default: + return -1; -static int xpcs_get_state(struct mdio_xpcs_args *xpcs, - struct phylink_link_state *state) +static int xpcs_get_state_c73(struct mdio_xpcs_args *xpcs, + struct phylink_link_state *state) - state->link = xpcs_read_link(xpcs, state->an_enabled) > 0 ? 1 : 0; + state->link = xpcs_read_link_c73(xpcs, state->an_enabled) > 0 ? 1 : 0; - ret = xpcs_read_fault(xpcs, state); + ret = xpcs_read_fault_c73(xpcs, state); - ret = xpcs_soft_reset(xpcs, mdio_mmd_pcs); + ret = xpcs_soft_reset(xpcs); - if (state->an_enabled && xpcs_aneg_done(xpcs, state)) { + if (state->an_enabled && xpcs_aneg_done_c73(xpcs, state)) { - xpcs_read_lpa(xpcs, state); - xpcs_resolve_lpa(xpcs, state); + xpcs_read_lpa_c73(xpcs, state); + xpcs_resolve_lpa_c73(xpcs, state); +static int xpcs_get_state(struct mdio_xpcs_args *xpcs, + struct phylink_link_state *state) +{ + int ret; + + switch (xpcs->an_mode) { + case dw_an_c73: + ret = xpcs_get_state_c73(xpcs, state); + if (ret) + return ret; + break; + default: + return -1; + } + + return 0; +} + + xpcs->an_mode = match->an_mode; + - return xpcs_soft_reset(xpcs, mdio_mmd_pcs); + return xpcs_soft_reset(xpcs); diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h +/* an mode */ +#define dw_an_c73 1 + + int an_mode;
|
Networking
|
07a4bc51fc732b3618fd46dc51609948933064a4
|
ong boon leong
|
drivers
|
net
|
pcs
|
net: phylink: make phylink_parse_mode() support non-dt platform
|
certain platform does not support dt, so we make phylink_parse_mode() to allow non-dt platform to use it to setup in-band an advertising.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add c37 an sgmii support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 2
| 5
| 2
|
--- diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c - if (fwnode_property_read_string(fwnode, "managed", &managed) == 0 && - strcmp(managed, "in-band-status") == 0) { + if ((fwnode_property_read_string(fwnode, "managed", &managed) == 0 && + strcmp(managed, "in-band-status") == 0) || + pl->config->ovr_an_inband) { diff --git a/include/linux/phylink.h b/include/linux/phylink.h --- a/include/linux/phylink.h +++ b/include/linux/phylink.h + * @ovr_an_inband: if true, override pcs to mlo_an_inband + bool ovr_an_inband;
|
Networking
|
ab39385021d1e0b4cd6cc521dc35c2fe659bbddf
|
ong boon leong
|
include
|
linux
|
phy
|
net: stmmac: make in-band an mode parsing is supported for non-dt
|
not all platform uses dt, so phylink_parse_mode() will skip in-band setup of pl->supported and pl->link_config.advertising entirely. so, we add the setting of ovr_an_inband flag to make it works for non-dt platform.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add c37 an sgmii support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 2
| 3
| 0
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + priv->phylink_config.ovr_an_inband = + priv->plat->mdio_bus_data->xpcs_an_inband; diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h + unsigned int xpcs_an_inband;
|
Networking
|
e5e5b771f684c22b25c67df85d2deb43901f7b95
|
ong boon leong
|
include
|
linux
|
ethernet, stmicro, stmmac
|
net: stmmac: ensure phydev is attached to phylink for c37 an
|
as the support for mac-side sgmii c37 an is added to pcs-xpcs, phydev should be attached to phylink during driver's open(). so, we change the condition to "not c73 an" instead.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add c37 an sgmii support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 1
| 1
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c - priv->hw->xpcs == null) { + priv->hw->xpcs_args.an_mode != dw_an_c73) {
|
Networking
|
c62808e8105f6a0872ac716c0030e97af81e4cf0
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
stmmac: intel: add pcs-xpcs for intel mgbe controller
|
intel mgbe controller such as those in ehl & tgl uses pcs-xpcs driver for sgmii interface. to ensure mdio bus scanning does not assign phy_device to mdio-addressable entities like intel serdes and pcs-xpcs, we set up to phy_mask to skip them.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add c37 an sgmii support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 14
| 1
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +#define intel_mgbe_adhoc_addr 0x15 +#define intel_mgbe_xpcs_addr 0x16 + + /* intel mgbe sgmii interface uses pcs-xcps */ + if (plat->phy_interface == phy_interface_mode_sgmii) { + plat->mdio_bus_data->has_xpcs = true; + plat->mdio_bus_data->xpcs_an_inband = true; + } + + /* ensure mdio bus scan skips intel serdes and pcs-xpcs */ + plat->mdio_bus_data->phy_mask = 1 << intel_mgbe_adhoc_addr; + plat->mdio_bus_data->phy_mask |= 1 << intel_mgbe_xpcs_addr; + - intel_priv->mdio_adhoc_addr = 0x15; + intel_priv->mdio_adhoc_addr = intel_mgbe_adhoc_addr;
|
Networking
|
7310fe538ea5c966a773cbc39272ef145f8d05ae
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: introduce dma interrupt status masking per traffic direction
|
in preparation to make stmmac support multi-vector msi, we introduce the interrupt status masking according to rx, tx or rxtx. default to use rxtx inside stmmac_dma_interrupt(), so there is no run-time logic difference now.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
enable multi-vector msi
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 10
| 101
| 10
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h +enum dma_irq_dir { + dma_dir_rx = 0x1, + dma_dir_tx = 0x2, + dma_dir_rxtx = 0x3, +}; + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +#define emac_int_msk_common emac_rgmii_sta_int +#define emac_int_msk_tx (emac_tx_int | \ + emac_tx_dma_stop_int | \ + emac_tx_buf_ua_int | \ + emac_tx_timeout_int | \ + emac_tx_underflow_int | \ + emac_tx_early_int |\ + emac_int_msk_common) +#define emac_int_msk_rx (emac_rx_int | \ + emac_rx_buf_ua_int | \ + emac_rx_dma_stop_int | \ + emac_rx_timeout_int | \ + emac_rx_overflow_int | \ + emac_rx_early_int | \ + emac_int_msk_common) + - struct stmmac_extra_stats *x, u32 chan) + struct stmmac_extra_stats *x, u32 chan, + u32 dir) + if (dir == dma_dir_rx) + v &= emac_int_msk_rx; + else if (dir == dma_dir_tx) + v &= emac_int_msk_tx; + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h +#define dma_chan_status_msk_common (dma_chan_status_nis | \ + dma_chan_status_ais | \ + dma_chan_status_cde | \ + dma_chan_status_fbe) + +#define dma_chan_status_msk_rx (dma_chan_status_reb | \ + dma_chan_status_eri | \ + dma_chan_status_rwt | \ + dma_chan_status_rps | \ + dma_chan_status_rbu | \ + dma_chan_status_ri | \ + dma_chan_status_msk_common) + +#define dma_chan_status_msk_tx (dma_chan_status_eti | \ + dma_chan_status_tbu | \ + dma_chan_status_tps | \ + dma_chan_status_ti | \ + dma_chan_status_msk_common) + - struct stmmac_extra_stats *x, u32 chan); + struct stmmac_extra_stats *x, u32 chan, u32 dir); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c - struct stmmac_extra_stats *x, u32 chan) + struct stmmac_extra_stats *x, u32 chan, u32 dir) + if (dir == dma_dir_rx) + intr_status &= dma_chan_status_msk_rx; + else if (dir == dma_dir_tx) + intr_status &= dma_chan_status_msk_tx; + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h +#define dma_status_msk_common (dma_status_nis | \ + dma_status_ais | \ + dma_status_fbi) + +#define dma_status_msk_rx (dma_status_eri | \ + dma_status_rwt | \ + dma_status_rps | \ + dma_status_ru | \ + dma_status_ri | \ + dma_status_ovf | \ + dma_status_msk_common) + +#define dma_status_msk_tx (dma_status_eti | \ + dma_status_unf | \ + dma_status_tjt | \ + dma_status_tu | \ + dma_status_tps | \ + dma_status_ti | \ + dma_status_msk_common) + - u32 chan); + u32 chan, u32 dir); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c - struct stmmac_extra_stats *x, u32 chan) + struct stmmac_extra_stats *x, u32 chan, u32 dir) + + if (dir == dma_dir_rx) + intr_status &= dma_status_msk_rx; + else if (dir == dma_dir_tx) + intr_status &= dma_status_msk_tx; + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +#define xgmac_dma_status_msk_common (xgmac_nis | xgmac_ais | xgmac_fbe) +#define xgmac_dma_status_msk_rx (xgmac_rbu | xgmac_ri | \ + xgmac_dma_status_msk_common) +#define xgmac_dma_status_msk_tx (xgmac_tbu | xgmac_tps | xgmac_ti | \ + xgmac_dma_status_msk_common) + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c - struct stmmac_extra_stats *x, u32 chan) + struct stmmac_extra_stats *x, u32 chan, + u32 dir) + if (dir == dma_dir_rx) + intr_status &= xgmac_dma_status_msk_rx; + else if (dir == dma_dir_tx) + intr_status &= xgmac_dma_status_msk_tx; + diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h - struct stmmac_extra_stats *x, u32 chan); + struct stmmac_extra_stats *x, u32 chan, u32 dir); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c -static int stmmac_napi_check(struct stmmac_priv *priv, u32 chan) +static int stmmac_napi_check(struct stmmac_priv *priv, u32 chan, u32 dir) - &priv->xstats, chan); + &priv->xstats, chan, dir); - status[chan] = stmmac_napi_check(priv, chan); + status[chan] = stmmac_napi_check(priv, chan, + dma_dir_rxtx);
|
Networking
|
7e1c520c0d2028e24cf86df811d41dc4205dc5d4
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: make stmmac_interrupt() function more friendly to msi
|
refactor stmmac_interrupt() by introducing stmmac_common_interrupt() so that we prepare the isr operation to be friendly to msi later.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
enable multi-vector msi
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 31
| 23
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c -/** - * stmmac_interrupt - main isr - * @irq: interrupt number. - * @dev_id: to pass the net device pointer (must be valid). - * description: this is the main driver interrupt service routine. - * it can call: - * o dma service routine (to manage incoming frame reception and transmission - * status) - * o core interrupts to manage: remote wake-up, management counter, lpi - * interrupts. - */ -static irqreturn_t stmmac_interrupt(int irq, void *dev_id) +static void stmmac_common_interrupt(struct stmmac_priv *priv) - struct net_device *dev = (struct net_device *)dev_id; - struct stmmac_priv *priv = netdev_priv(dev); - /* check if adapter is up */ - if (test_bit(stmmac_down, &priv->state)) - return irq_handled; - /* check if a fatal error happened */ - if (stmmac_safety_feat_interrupt(priv)) - return irq_handled; - - netif_carrier_on(dev); + netif_carrier_on(priv->dev); - netif_carrier_off(dev); + netif_carrier_off(priv->dev); +} + +/** + * stmmac_interrupt - main isr + * @irq: interrupt number. + * @dev_id: to pass the net device pointer. + * description: this is the main driver interrupt service routine. + * it can call: + * o dma service routine (to manage incoming frame reception and transmission + * status) + * o core interrupts to manage: remote wake-up, management counter, lpi + * interrupts. + */ +static irqreturn_t stmmac_interrupt(int irq, void *dev_id) +{ + struct net_device *dev = (struct net_device *)dev_id; + struct stmmac_priv *priv = netdev_priv(dev); + + /* check if adapter is up */ + if (test_bit(stmmac_down, &priv->state)) + return irq_handled; + + /* check if a fatal error happened */ + if (stmmac_safety_feat_interrupt(priv)) + return irq_handled; + + /* to handle common interrupts */ + stmmac_common_interrupt(priv);
|
Networking
|
29e6573c61aaa71010e711e6c3249c56a2e61b46
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: introduce msi interrupt routines for mac, safety, rx & tx
|
now we introduce msi interrupt service routines and hook these routines up if stmmac_open() sees valid irq line being requested:-
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
enable multi-vector msi
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 4
| 431
| 45
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h +/* msi defines */ +#define stmmac_msi_vec_max 32 + +enum request_irq_err { + req_irq_err_all, + req_irq_err_tx, + req_irq_err_rx, + req_irq_err_sfty_ue, + req_irq_err_sfty_ce, + req_irq_err_lpi, + req_irq_err_wol, + req_irq_err_mac, + req_irq_err_no, +}; + diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h + int sfty_ce_irq; + int sfty_ue_irq; + int rx_irq[mtl_max_rx_queues]; + int tx_irq[mtl_max_tx_queues]; + int sfty_ce_irq; + int sfty_ue_irq; + int rx_irq[mtl_max_rx_queues]; + int tx_irq[mtl_max_tx_queues]; + /*irq name */ + char int_name_mac[ifnamsiz + 9]; + char int_name_wol[ifnamsiz + 9]; + char int_name_lpi[ifnamsiz + 9]; + char int_name_sfty_ce[ifnamsiz + 10]; + char int_name_sfty_ue[ifnamsiz + 10]; + char int_name_rx_irq[mtl_max_tx_queues][ifnamsiz + 14]; + char int_name_tx_irq[mtl_max_tx_queues][ifnamsiz + 18]; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +/* for msi interrupts handling */ +static irqreturn_t stmmac_mac_interrupt(int irq, void *dev_id); +static irqreturn_t stmmac_safety_interrupt(int irq, void *dev_id); +static irqreturn_t stmmac_msi_intr_tx(int irq, void *data); +static irqreturn_t stmmac_msi_intr_rx(int irq, void *data); +static void stmmac_free_irq(struct net_device *dev, + enum request_irq_err irq_err, int irq_idx) +{ + struct stmmac_priv *priv = netdev_priv(dev); + int j; + + switch (irq_err) { + case req_irq_err_all: + irq_idx = priv->plat->tx_queues_to_use; + fallthrough; + case req_irq_err_tx: + for (j = irq_idx - 1; j >= 0; j--) { + if (priv->tx_irq[j] > 0) + free_irq(priv->tx_irq[j], &priv->tx_queue[j]); + } + irq_idx = priv->plat->rx_queues_to_use; + fallthrough; + case req_irq_err_rx: + for (j = irq_idx - 1; j >= 0; j--) { + if (priv->rx_irq[j] > 0) + free_irq(priv->rx_irq[j], &priv->rx_queue[j]); + } + + if (priv->sfty_ue_irq > 0 && priv->sfty_ue_irq != dev->irq) + free_irq(priv->sfty_ue_irq, dev); + fallthrough; + case req_irq_err_sfty_ue: + if (priv->sfty_ce_irq > 0 && priv->sfty_ce_irq != dev->irq) + free_irq(priv->sfty_ce_irq, dev); + fallthrough; + case req_irq_err_sfty_ce: + if (priv->lpi_irq > 0 && priv->lpi_irq != dev->irq) + free_irq(priv->lpi_irq, dev); + fallthrough; + case req_irq_err_lpi: + if (priv->wol_irq > 0 && priv->wol_irq != dev->irq) + free_irq(priv->wol_irq, dev); + fallthrough; + case req_irq_err_wol: + free_irq(dev->irq, dev); + fallthrough; + case req_irq_err_mac: + case req_irq_err_no: + /* if mac irq request error, no more irq to free */ + break; + } +} + +static int stmmac_request_irq_multi_msi(struct net_device *dev) +{ + enum request_irq_err irq_err = req_irq_err_no; + struct stmmac_priv *priv = netdev_priv(dev); + int irq_idx = 0; + char *int_name; + int ret; + int i; + + /* for common interrupt */ + int_name = priv->int_name_mac; + sprintf(int_name, "%s:%s", dev->name, "mac"); + ret = request_irq(dev->irq, stmmac_mac_interrupt, + 0, int_name, dev); + if (unlikely(ret < 0)) { + netdev_err(priv->dev, + "%s: alloc mac msi %d (error: %d) ", + __func__, dev->irq, ret); + irq_err = req_irq_err_mac; + goto irq_error; + } + + /* request the wake irq in case of another line + * is used for wol + */ + if (priv->wol_irq > 0 && priv->wol_irq != dev->irq) { + int_name = priv->int_name_wol; + sprintf(int_name, "%s:%s", dev->name, "wol"); + ret = request_irq(priv->wol_irq, + stmmac_mac_interrupt, + 0, int_name, dev); + if (unlikely(ret < 0)) { + netdev_err(priv->dev, + "%s: alloc wol msi %d (error: %d) ", + __func__, priv->wol_irq, ret); + irq_err = req_irq_err_wol; + goto irq_error; + } + } + + /* request the lpi irq in case of another line + * is used for lpi + */ + if (priv->lpi_irq > 0 && priv->lpi_irq != dev->irq) { + int_name = priv->int_name_lpi; + sprintf(int_name, "%s:%s", dev->name, "lpi"); + ret = request_irq(priv->lpi_irq, + stmmac_mac_interrupt, + 0, int_name, dev); + if (unlikely(ret < 0)) { + netdev_err(priv->dev, + "%s: alloc lpi msi %d (error: %d) ", + __func__, priv->lpi_irq, ret); + irq_err = req_irq_err_lpi; + goto irq_error; + } + } + + /* request the safety feature correctible error line in + * case of another line is used + */ + if (priv->sfty_ce_irq > 0 && priv->sfty_ce_irq != dev->irq) { + int_name = priv->int_name_sfty_ce; + sprintf(int_name, "%s:%s", dev->name, "safety-ce"); + ret = request_irq(priv->sfty_ce_irq, + stmmac_safety_interrupt, + 0, int_name, dev); + if (unlikely(ret < 0)) { + netdev_err(priv->dev, + "%s: alloc sfty ce msi %d (error: %d) ", + __func__, priv->sfty_ce_irq, ret); + irq_err = req_irq_err_sfty_ce; + goto irq_error; + } + } + + /* request the safety feature uncorrectible error line in + * case of another line is used + */ + if (priv->sfty_ue_irq > 0 && priv->sfty_ue_irq != dev->irq) { + int_name = priv->int_name_sfty_ue; + sprintf(int_name, "%s:%s", dev->name, "safety-ue"); + ret = request_irq(priv->sfty_ue_irq, + stmmac_safety_interrupt, + 0, int_name, dev); + if (unlikely(ret < 0)) { + netdev_err(priv->dev, + "%s: alloc sfty ue msi %d (error: %d) ", + __func__, priv->sfty_ue_irq, ret); + irq_err = req_irq_err_sfty_ue; + goto irq_error; + } + } + + /* request rx msi irq */ + for (i = 0; i < priv->plat->rx_queues_to_use; i++) { + if (priv->rx_irq[i] == 0) + continue; + + int_name = priv->int_name_rx_irq[i]; + sprintf(int_name, "%s:%s-%d", dev->name, "rx", i); + ret = request_irq(priv->rx_irq[i], + stmmac_msi_intr_rx, + 0, int_name, &priv->rx_queue[i]); + if (unlikely(ret < 0)) { + netdev_err(priv->dev, + "%s: alloc rx-%d msi %d (error: %d) ", + __func__, i, priv->rx_irq[i], ret); + irq_err = req_irq_err_rx; + irq_idx = i; + goto irq_error; + } + } + + /* request tx msi irq */ + for (i = 0; i < priv->plat->tx_queues_to_use; i++) { + if (priv->tx_irq[i] == 0) + continue; + + int_name = priv->int_name_tx_irq[i]; + sprintf(int_name, "%s:%s-%d", dev->name, "tx", i); + ret = request_irq(priv->tx_irq[i], + stmmac_msi_intr_tx, + 0, int_name, &priv->tx_queue[i]); + if (unlikely(ret < 0)) { + netdev_err(priv->dev, + "%s: alloc tx-%d msi %d (error: %d) ", + __func__, i, priv->tx_irq[i], ret); + irq_err = req_irq_err_tx; + irq_idx = i; + goto irq_error; + } + } + + return 0; + +irq_error: + stmmac_free_irq(dev, irq_err, irq_idx); + return ret; +} + +static int stmmac_request_irq_single(struct net_device *dev) +{ + enum request_irq_err irq_err = req_irq_err_no; + struct stmmac_priv *priv = netdev_priv(dev); + int ret; + + ret = request_irq(dev->irq, stmmac_interrupt, + irqf_shared, dev->name, dev); + if (unlikely(ret < 0)) { + netdev_err(priv->dev, + "%s: error: allocating the irq %d (error: %d) ", + __func__, dev->irq, ret); + irq_err = req_irq_err_mac; + return ret; + } + + /* request the wake irq in case of another line + * is used for wol + */ + if (priv->wol_irq > 0 && priv->wol_irq != dev->irq) { + ret = request_irq(priv->wol_irq, stmmac_interrupt, + irqf_shared, dev->name, dev); + if (unlikely(ret < 0)) { + netdev_err(priv->dev, + "%s: error: allocating the wol irq %d (%d) ", + __func__, priv->wol_irq, ret); + irq_err = req_irq_err_wol; + return ret; + } + } + + /* request the irq lines */ + if (priv->lpi_irq > 0 && priv->lpi_irq != dev->irq) { + ret = request_irq(priv->lpi_irq, stmmac_interrupt, + irqf_shared, dev->name, dev); + if (unlikely(ret < 0)) { + netdev_err(priv->dev, + "%s: error: allocating the lpi irq %d (%d) ", + __func__, priv->lpi_irq, ret); + irq_err = req_irq_err_lpi; + goto irq_error; + } + } + + return 0; + +irq_error: + stmmac_free_irq(dev, irq_err, 0); + return ret; +} + +static int stmmac_request_irq(struct net_device *dev) +{ + struct stmmac_priv *priv = netdev_priv(dev); + int ret; + + /* request the irq lines */ + if (priv->plat->multi_msi_en) + ret = stmmac_request_irq_multi_msi(dev); + else + ret = stmmac_request_irq_single(dev); + + return ret; +} + - /* request the irq lines */ - ret = request_irq(dev->irq, stmmac_interrupt, - irqf_shared, dev->name, dev); - if (unlikely(ret < 0)) { - netdev_err(priv->dev, - "%s: error: allocating the irq %d (error: %d) ", - __func__, dev->irq, ret); + ret = stmmac_request_irq(dev); + if (ret) - } - - /* request the wake irq in case of another line is used for wol */ - if (priv->wol_irq != dev->irq) { - ret = request_irq(priv->wol_irq, stmmac_interrupt, - irqf_shared, dev->name, dev); - if (unlikely(ret < 0)) { - netdev_err(priv->dev, - "%s: error: allocating the wol irq %d (%d) ", - __func__, priv->wol_irq, ret); - goto wolirq_error; - } - } - - /* request the irq lines */ - if (priv->lpi_irq > 0) { - ret = request_irq(priv->lpi_irq, stmmac_interrupt, irqf_shared, - dev->name, dev); - if (unlikely(ret < 0)) { - netdev_err(priv->dev, - "%s: error: allocating the lpi irq %d (%d) ", - __func__, priv->lpi_irq, ret); - goto lpiirq_error; - } - } -lpiirq_error: - if (priv->wol_irq != dev->irq) - free_irq(priv->wol_irq, dev); -wolirq_error: - free_irq(dev->irq, dev); - free_irq(dev->irq, dev); - if (priv->wol_irq != dev->irq) - free_irq(priv->wol_irq, dev); - if (priv->lpi_irq > 0) - free_irq(priv->lpi_irq, dev); + stmmac_free_irq(dev, req_irq_err_all, 0); +static irqreturn_t stmmac_mac_interrupt(int irq, void *dev_id) +{ + struct net_device *dev = (struct net_device *)dev_id; + struct stmmac_priv *priv = netdev_priv(dev); + + if (unlikely(!dev)) { + netdev_err(priv->dev, "%s: invalid dev pointer ", __func__); + return irq_none; + } + + /* check if adapter is up */ + if (test_bit(stmmac_down, &priv->state)) + return irq_handled; + + /* to handle common interrupts */ + stmmac_common_interrupt(priv); + + return irq_handled; +} + +static irqreturn_t stmmac_safety_interrupt(int irq, void *dev_id) +{ + struct net_device *dev = (struct net_device *)dev_id; + struct stmmac_priv *priv = netdev_priv(dev); + + if (unlikely(!dev)) { + netdev_err(priv->dev, "%s: invalid dev pointer ", __func__); + return irq_none; + } + + /* check if adapter is up */ + if (test_bit(stmmac_down, &priv->state)) + return irq_handled; + + /* check if a fatal error happened */ + stmmac_safety_feat_interrupt(priv); + + return irq_handled; +} + +static irqreturn_t stmmac_msi_intr_tx(int irq, void *data) +{ + struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)data; + int chan = tx_q->queue_index; + struct stmmac_priv *priv; + int status; + + priv = container_of(tx_q, struct stmmac_priv, tx_queue[chan]); + + if (unlikely(!data)) { + netdev_err(priv->dev, "%s: invalid dev pointer ", __func__); + return irq_none; + } + + /* check if adapter is up */ + if (test_bit(stmmac_down, &priv->state)) + return irq_handled; + + status = stmmac_napi_check(priv, chan, dma_dir_tx); + + if (unlikely(status & tx_hard_error_bump_tc)) { + /* try to bump up the dma threshold on this failure */ + if (unlikely(priv->xstats.threshold != sf_dma_mode) && + tc <= 256) { + tc += 64; + if (priv->plat->force_thresh_dma_mode) + stmmac_set_dma_operation_mode(priv, + tc, + tc, + chan); + else + stmmac_set_dma_operation_mode(priv, + tc, + sf_dma_mode, + chan); + priv->xstats.threshold = tc; + } + } else if (unlikely(status == tx_hard_error)) { + stmmac_tx_err(priv, chan); + } + + return irq_handled; +} + +static irqreturn_t stmmac_msi_intr_rx(int irq, void *data) +{ + struct stmmac_rx_queue *rx_q = (struct stmmac_rx_queue *)data; + int chan = rx_q->queue_index; + struct stmmac_priv *priv; + + priv = container_of(rx_q, struct stmmac_priv, rx_queue[chan]); + + if (unlikely(!data)) { + netdev_err(priv->dev, "%s: invalid dev pointer ", __func__); + return irq_none; + } + + /* check if adapter is up */ + if (test_bit(stmmac_down, &priv->state)) + return irq_handled; + + stmmac_napi_check(priv, chan, dma_dir_rx); + + return irq_handled; +} + - disable_irq(dev->irq); - stmmac_interrupt(dev->irq, dev); - enable_irq(dev->irq); + struct stmmac_priv *priv = netdev_priv(dev); + int i; + + /* if adapter is down, do nothing */ + if (test_bit(stmmac_down, &priv->state)) + return; + + if (priv->plat->multi_msi_en) { + for (i = 0; i < priv->plat->rx_queues_to_use; i++) + stmmac_msi_intr_rx(0, &priv->rx_queue[i]); + + for (i = 0; i < priv->plat->tx_queues_to_use; i++) + stmmac_msi_intr_tx(0, &priv->tx_queue[i]); + } else { + disable_irq(dev->irq); + stmmac_interrupt(dev->irq, dev); + enable_irq(dev->irq); + } + priv->sfty_ce_irq = res->sfty_ce_irq; + priv->sfty_ue_irq = res->sfty_ue_irq; + for (i = 0; i < mtl_max_rx_queues; i++) + priv->rx_irq[i] = res->rx_irq[i]; + for (i = 0; i < mtl_max_tx_queues; i++) + priv->tx_irq[i] = res->tx_irq[i]; diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h + bool multi_msi_en; + int msi_mac_vec; + int msi_wol_vec; + int msi_lpi_vec; + int msi_sfty_ce_vec; + int msi_sfty_ue_vec; + int msi_rx_base_vec; + int msi_tx_base_vec;
|
Networking
|
8532f613bc78b6e0e32b486e720848d3f5569287
|
ong boon leong
|
include
|
linux
|
ethernet, stmicro, stmmac
|
stmmac: intel: add support for multi-vector msi and msi-x
|
intel mgbe controller supports multi-vector interrupts: msi_rx_vec 0,2,4,6,8,10,12,14 msi_tx_vec 1,3,5,7,9,11,13,15 msi_sfty_ue_vec 26 msi_sfty_ce_vec 27 msi_lpi_vec 28 msi_mac_vec 29
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
enable multi-vector msi
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['c']
| 1
| 111
| 9
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c + /* setup msi vector offset specific to intel mgbe controller */ + plat->msi_mac_vec = 29; + plat->msi_lpi_vec = 28; + plat->msi_sfty_ce_vec = 27; + plat->msi_sfty_ue_vec = 26; + plat->msi_rx_base_vec = 0; + plat->msi_tx_base_vec = 1; + +static int stmmac_config_single_msi(struct pci_dev *pdev, + struct plat_stmmacenet_data *plat, + struct stmmac_resources *res) +{ + int ret; + + ret = pci_alloc_irq_vectors(pdev, 1, 1, pci_irq_all_types); + if (ret < 0) { + dev_info(&pdev->dev, "%s: single irq enablement failed ", + __func__); + return ret; + } + + res->irq = pci_irq_vector(pdev, 0); + res->wol_irq = res->irq; + plat->multi_msi_en = 0; + dev_info(&pdev->dev, "%s: single irq enablement successful ", + __func__); + + return 0; +} + +static int stmmac_config_multi_msi(struct pci_dev *pdev, + struct plat_stmmacenet_data *plat, + struct stmmac_resources *res) +{ + int ret; + int i; + + if (plat->msi_rx_base_vec >= stmmac_msi_vec_max || + plat->msi_tx_base_vec >= stmmac_msi_vec_max) { + dev_info(&pdev->dev, "%s: invalid rx & tx vector defined ", + __func__); + return -1; + } + + ret = pci_alloc_irq_vectors(pdev, 2, stmmac_msi_vec_max, + pci_irq_msi | pci_irq_msix); + if (ret < 0) { + dev_info(&pdev->dev, "%s: multi msi enablement failed ", + __func__); + return ret; + } + + /* for rx msi */ + for (i = 0; i < plat->rx_queues_to_use; i++) { + res->rx_irq[i] = pci_irq_vector(pdev, + plat->msi_rx_base_vec + i * 2); + } + + /* for tx msi */ + for (i = 0; i < plat->tx_queues_to_use; i++) { + res->tx_irq[i] = pci_irq_vector(pdev, + plat->msi_tx_base_vec + i * 2); + } + + if (plat->msi_mac_vec < stmmac_msi_vec_max) + res->irq = pci_irq_vector(pdev, plat->msi_mac_vec); + if (plat->msi_wol_vec < stmmac_msi_vec_max) + res->wol_irq = pci_irq_vector(pdev, plat->msi_wol_vec); + if (plat->msi_lpi_vec < stmmac_msi_vec_max) + res->lpi_irq = pci_irq_vector(pdev, plat->msi_lpi_vec); + if (plat->msi_sfty_ce_vec < stmmac_msi_vec_max) + res->sfty_ce_irq = pci_irq_vector(pdev, plat->msi_sfty_ce_vec); + if (plat->msi_sfty_ue_vec < stmmac_msi_vec_max) + res->sfty_ue_irq = pci_irq_vector(pdev, plat->msi_sfty_ue_vec); + + plat->multi_msi_en = 1; + dev_info(&pdev->dev, "%s: multi msi enablement successful ", __func__); + + return 0; +} + + /* initialize all msi vectors to invalid so that it can be set + * according to platform data settings below. + * note: msi vector takes value from 0 upto 31 (stmmac_msi_vec_max) + */ + plat->msi_mac_vec = stmmac_msi_vec_max; + plat->msi_wol_vec = stmmac_msi_vec_max; + plat->msi_lpi_vec = stmmac_msi_vec_max; + plat->msi_sfty_ce_vec = stmmac_msi_vec_max; + plat->msi_sfty_ue_vec = stmmac_msi_vec_max; + plat->msi_rx_base_vec = stmmac_msi_vec_max; + plat->msi_tx_base_vec = stmmac_msi_vec_max; + - ret = pci_alloc_irq_vectors(pdev, 1, 1, pci_irq_all_types); - if (ret < 0) - return ret; - - res.wol_irq = pci_irq_vector(pdev, 0); - res.irq = pci_irq_vector(pdev, 0); + ret = stmmac_config_multi_msi(pdev, plat, &res); + if (ret) { + ret = stmmac_config_single_msi(pdev, plat, &res); + if (ret) { + dev_err(&pdev->dev, "%s: error: failed to enable irq ", + __func__); + goto err_alloc_irq; + } + } + - pci_free_irq_vectors(pdev); - clk_disable_unprepare(plat->stmmac_clk); - clk_unregister_fixed_rate(plat->stmmac_clk); + goto err_dvr_probe; + return 0; + +err_dvr_probe: + pci_free_irq_vectors(pdev); +err_alloc_irq: + clk_disable_unprepare(plat->stmmac_clk); + clk_unregister_fixed_rate(plat->stmmac_clk);
|
Networking
|
b42446b9b37ba444ba12d89dd9d45c2b68768f24
|
ong boon leong
|
drivers
|
net
|
ethernet, stmicro, stmmac
|
net: stmmac: use interrupt mode intm=1 for multi-msi
|
for interrupt mode intm=0, tx/rx transfer complete will trigger signal not only on sbd_perch_[tx|rx]_intr_o (transmit/receive per channel) but also on the sbd_intr_o (common).
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
enable multi-vector msi
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 5
| 23
| 12
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c + + if (dma_cfg->multi_msi_en) { + value = readl(ioaddr + dma_bus_mode); + value &= ~dma_bus_mode_intm_mask; + value |= (dma_bus_mode_intm_mode1 << dma_bus_mode_intm_shift); + writel(value, ioaddr + dma_bus_mode); + } diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h +#define dma_bus_mode_intm_mask genmask(17, 16) +#define dma_bus_mode_intm_shift 16 +#define dma_bus_mode_intm_mode1 0x1 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c - if (likely(intr_status & dma_chan_status_nis)) { + if (likely(intr_status & dma_chan_status_nis)) - if (likely(intr_status & dma_chan_status_ri)) { - x->rx_normal_irq_n++; - ret |= handle_rx; - } - if (likely(intr_status & (dma_chan_status_ti | - dma_chan_status_tbu))) { - x->tx_normal_irq_n++; - ret |= handle_tx; - } - if (unlikely(intr_status & dma_chan_status_eri)) - x->rx_early_irq++; + if (likely(intr_status & dma_chan_status_ri)) { + x->rx_normal_irq_n++; + ret |= handle_rx; + } + if (likely(intr_status & (dma_chan_status_ti | + dma_chan_status_tbu))) { + x->tx_normal_irq_n++; + ret |= handle_tx; + if (unlikely(intr_status & dma_chan_status_eri)) + x->rx_early_irq++; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c + priv->plat->dma_cfg->multi_msi_en = priv->plat->multi_msi_en; diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h + bool multi_msi_en;
|
Networking
|
6ccf12ae111e49324b439410066e8cc359aeee6d
|
wong vee khee
|
include
|
linux
|
ethernet, stmicro, stmmac
|
net: stmmac: support fpe link partner hand-shaking procedure
|
in order to discover whether remote station supports frame preemption, local station sends verify mpacket and expects response mpacket in return from the remote station.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
support fpe link partner hand-shaking procedure
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['stmmac ']
|
['h', 'c']
| 9
| 331
| 7
|
--- diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h +/* fpe defines */ +#define fpe_event_unknown 0 +#define fpe_event_trsp bit(0) +#define fpe_event_tver bit(1) +#define fpe_event_rrsp bit(2) +#define fpe_event_rver bit(3) + diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c + /* enable fpe interrupt */ + if ((gmac_hw_feat_fpesel & readl(ioaddr + gmac_hw_feature3)) >> 26) + value |= gmac_int_fpe_en; + + .fpe_send_mpacket = dwmac5_fpe_send_mpacket, + .fpe_irq_status = dwmac5_fpe_irq_status, + .fpe_send_mpacket = dwmac5_fpe_send_mpacket, + .fpe_irq_status = dwmac5_fpe_irq_status, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c + +int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) +{ + u32 value; + int status; + + status = fpe_event_unknown; + + value = readl(ioaddr + mac_fpe_ctrl_sts); + + if (value & trsp) { + status |= fpe_event_trsp; + netdev_info(dev, "fpe: respond mpacket is transmitted "); + } + + if (value & tver) { + status |= fpe_event_tver; + netdev_info(dev, "fpe: verify mpacket is transmitted "); + } + + if (value & rrsp) { + status |= fpe_event_rrsp; + netdev_info(dev, "fpe: respond mpacket is received "); + } + + if (value & rver) { + status |= fpe_event_rver; + netdev_info(dev, "fpe: verify mpacket is received "); + } + + return status; +} + +void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, enum stmmac_mpacket_type type) +{ + u32 value; + + value = readl(ioaddr + mac_fpe_ctrl_sts); + + if (type == mpacket_verify) { + value &= ~srsp; + value |= sver; + } else { + value &= ~sver; + value |= srsp; + } + + writel(value, ioaddr + mac_fpe_ctrl_sts); +} diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +#define trsp bit(19) +#define tver bit(18) +#define rrsp bit(17) +#define rver bit(16) +#define srsp bit(2) +#define sver bit(1) +#define gmac_int_fpe_en bit(17) + +void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, + enum stmmac_mpacket_type type); +int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev); diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h + void (*fpe_send_mpacket)(void __iomem *ioaddr, + enum stmmac_mpacket_type type); + int (*fpe_irq_status)(void __iomem *ioaddr, struct net_device *dev); +#define stmmac_fpe_send_mpacket(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, fpe_send_mpacket, __args) +#define stmmac_fpe_irq_status(__priv, __args...) \ + stmmac_do_callback(__priv, mac, fpe_irq_status, __args) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h + /* workqueue for handling fpe hand-shaking */ + unsigned long fpe_task_state; + struct workqueue_struct *fpe_wq; + struct work_struct fpe_task; + char wq_name[ifnamsiz + 4]; + +void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) +{ + struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg; + enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; + enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; + bool *hs_enable = &fpe_cfg->hs_enable; + + if (is_up && *hs_enable) { + stmmac_fpe_send_mpacket(priv, priv->ioaddr, mpacket_verify); + } else { + *lo_state = fpe_event_unknown; + *lp_state = fpe_event_unknown; + } +} + + + stmmac_fpe_link_state_handle(priv, false); + + stmmac_fpe_link_state_handle(priv, true); +static int stmmac_fpe_start_wq(struct stmmac_priv *priv) +{ + char *name; + + clear_bit(__fpe_task_sched, &priv->fpe_task_state); + + name = priv->wq_name; + sprintf(name, "%s-fpe", priv->dev->name); + + priv->fpe_wq = create_singlethread_workqueue(name); + if (!priv->fpe_wq) { + netdev_err(priv->dev, "%s: failed to create workqueue ", name); + + return -enomem; + } + netdev_info(priv->dev, "fpe workqueue start"); + + return 0; +} + + if (priv->dma_cap.fpesel) { + stmmac_fpe_start_wq(priv); + + if (priv->plat->fpe_cfg->enable) + stmmac_fpe_handshake(priv, true); + } + +static void stmmac_fpe_stop_wq(struct stmmac_priv *priv) +{ + set_bit(__fpe_removing, &priv->fpe_task_state); + + if (priv->fpe_wq) + destroy_workqueue(priv->fpe_wq); + + netdev_info(priv->dev, "fpe workqueue stop"); +} + + if (priv->dma_cap.fpesel) + stmmac_fpe_stop_wq(priv); + +static void stmmac_fpe_event_status(struct stmmac_priv *priv, int status) +{ + struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg; + enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; + enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; + bool *hs_enable = &fpe_cfg->hs_enable; + + if (status == fpe_event_unknown || !*hs_enable) + return; + + /* if lp has sent verify mpacket, lp is fpe capable */ + if ((status & fpe_event_rver) == fpe_event_rver) { + if (*lp_state < fpe_state_capable) + *lp_state = fpe_state_capable; + + /* if user has requested fpe enable, quickly response */ + if (*hs_enable) + stmmac_fpe_send_mpacket(priv, priv->ioaddr, + mpacket_response); + } + + /* if local has sent verify mpacket, local is fpe capable */ + if ((status & fpe_event_tver) == fpe_event_tver) { + if (*lo_state < fpe_state_capable) + *lo_state = fpe_state_capable; + } + + /* if lp has sent response mpacket, lp is entering fpe on */ + if ((status & fpe_event_rrsp) == fpe_event_rrsp) + *lp_state = fpe_state_entering_on; + + /* if local has sent response mpacket, local is entering fpe on */ + if ((status & fpe_event_trsp) == fpe_event_trsp) + *lo_state = fpe_state_entering_on; + + if (!test_bit(__fpe_removing, &priv->fpe_task_state) && + !test_and_set_bit(__fpe_task_sched, &priv->fpe_task_state) && + priv->fpe_wq) { + queue_work(priv->fpe_wq, &priv->fpe_task); + } +} + + if (priv->dma_cap.fpesel) { + int status = stmmac_fpe_irq_status(priv, priv->ioaddr, + priv->dev); + + stmmac_fpe_event_status(priv, status); + } + +#define send_verify_mpakcet_fmt "send verify mpacket lo_state=%d lp_state=%d " +static void stmmac_fpe_lp_task(struct work_struct *work) +{ + struct stmmac_priv *priv = container_of(work, struct stmmac_priv, + fpe_task); + struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg; + enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; + enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; + bool *hs_enable = &fpe_cfg->hs_enable; + bool *enable = &fpe_cfg->enable; + int retries = 20; + + while (retries-- > 0) { + /* bail out immediately if fpe handshake is off */ + if (*lo_state == fpe_state_off || !*hs_enable) + break; + + if (*lo_state == fpe_state_entering_on && + *lp_state == fpe_state_entering_on) { + stmmac_fpe_configure(priv, priv->ioaddr, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + *enable); + + netdev_info(priv->dev, "configured fpe "); + + *lo_state = fpe_state_on; + *lp_state = fpe_state_on; + netdev_info(priv->dev, "!!! both fpe stations on "); + break; + } + + if ((*lo_state == fpe_state_capable || + *lo_state == fpe_state_entering_on) && + *lp_state != fpe_state_on) { + netdev_info(priv->dev, send_verify_mpakcet_fmt, + *lo_state, *lp_state); + stmmac_fpe_send_mpacket(priv, priv->ioaddr, + mpacket_verify); + } + /* sleep then retry */ + msleep(500); + } + + clear_bit(__fpe_task_sched, &priv->fpe_task_state); +} + +void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable) +{ + if (priv->plat->fpe_cfg->hs_enable != enable) { + if (enable) { + stmmac_fpe_send_mpacket(priv, priv->ioaddr, + mpacket_verify); + } else { + priv->plat->fpe_cfg->lo_fpe_state = fpe_state_off; + priv->plat->fpe_cfg->lp_fpe_state = fpe_state_off; + } + + priv->plat->fpe_cfg->hs_enable = enable; + } +} + + /* initialize link partner fpe workqueue */ + init_work(&priv->fpe_task, stmmac_fpe_lp_task); + + + if (priv->dma_cap.fpesel) { + /* disable fpe */ + stmmac_fpe_configure(priv, priv->ioaddr, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, false); + + stmmac_fpe_handshake(priv, false); + } + diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c + + if (!priv->plat->fpe_cfg) { + priv->plat->fpe_cfg = devm_kzalloc(priv->device, + sizeof(*priv->plat->fpe_cfg), + gfp_kernel); + if (!priv->plat->fpe_cfg) + return -enomem; + } else { + memset(priv->plat->fpe_cfg, 0, sizeof(*priv->plat->fpe_cfg)); + } + - ret = stmmac_fpe_configure(priv, priv->ioaddr, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, fpe); - if (ret && fpe) { - netdev_err(priv->dev, "failed to enable frame preemption "); - return ret; - } + /* actual fpe register configuration will be done after fpe handshake + * is success. + */ + priv->plat->fpe_cfg->enable = fpe; + + if (fpe) { + stmmac_fpe_handshake(priv, true); + netdev_info(priv->dev, "start fpe handshake "); + } + + + priv->plat->fpe_cfg->enable = false; + stmmac_fpe_configure(priv, priv->ioaddr, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + false); + netdev_info(priv->dev, "disabled fpe "); + + stmmac_fpe_handshake(priv, false); + netdev_info(priv->dev, "stop fpe handshake "); + diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h +/* fpe link state */ +enum stmmac_fpe_state { + fpe_state_off = 0, + fpe_state_capable = 1, + fpe_state_entering_on = 2, + fpe_state_on = 3, +}; + +/* fpe link-partner hand-shaking mpacket type */ +enum stmmac_mpacket_type { + mpacket_verify = 0, + mpacket_response = 1, +}; + +enum stmmac_fpe_task_state_t { + __fpe_removing, + __fpe_task_sched, +}; + +struct stmmac_fpe_cfg { + bool enable; /* fpe enable */ + bool hs_enable; /* fpe handshake enable */ + enum stmmac_fpe_state lp_fpe_state; /* link partner fpe state */ + enum stmmac_fpe_state lo_fpe_state; /* local station fpe state */ +}; + + struct stmmac_fpe_cfg *fpe_cfg;
|
Networking
|
5a5586112b929546e16029261a987c9197bfdfa2
|
ong boon leong
|
include
|
linux
|
ethernet, stmicro, stmmac
|
wilc1000: add support for enabling crc
|
the driver so far has always disabled crc protection. this means any data corruption that occurrs during the spi transfers could go undetected. this patch adds module parameters enable_crc7 and enable_crc16 to selectively turn on crc7 (for command transfers) and crc16 (for data transfers), respectively.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for enabling crc
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['wilc1000 ']
|
['kconfig', 'c']
| 2
| 115
| 64
|
---- ----- ----------- ------------------- --- diff --git a/drivers/net/wireless/microchip/wilc1000/kconfig b/drivers/net/wireless/microchip/wilc1000/kconfig --- a/drivers/net/wireless/microchip/wilc1000/kconfig +++ b/drivers/net/wireless/microchip/wilc1000/kconfig + select crc_itu_t diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c --- a/drivers/net/wireless/microchip/wilc1000/spi.c +++ b/drivers/net/wireless/microchip/wilc1000/spi.c +#include <linux/crc-itu-t.h> +static bool enable_crc7; /* protect spi commands with crc7 */ +module_param(enable_crc7, bool, 0644); +module_parm_desc(enable_crc7, + "enable crc7 checksum to protect command transfers " + " against corruption during the spi transfer. " + " command transfers are short and the cpu-cycle cost " + " of enabling this is small."); + +static bool enable_crc16; /* protect spi data with crc16 */ +module_param(enable_crc16, bool, 0644); +module_parm_desc(enable_crc16, + "enable crc16 checksum to protect data transfers " + " against corruption during the spi transfer. " + " data transfers can be large and the cpu-cycle cost " + " of enabling this may be substantial."); + - int crc_off; + bool probing_crc; /* true if we're probing chip's crc config */ + bool crc7_enabled; /* true if crc7 is currently enabled */ + bool crc16_enabled; /* true if crc16 is currently enabled */ - u8 cmd, order, crc[2] = {0}; + u8 cmd, order, crc[2]; + u16 crc_calc; - * write crc + * write crc - if (!spi_priv->crc_off) { + if (spi_priv->crc16_enabled) { + crc_calc = crc_itu_t(0xffff, &b[ix], nbytes); + crc[0] = crc_calc >> 8; + crc[1] = crc_calc; - u8 crc[2]; + u16 crc_calc, crc_recv; - struct wilc_spi_read_rsp_data *r_data; + struct wilc_spi_read_rsp_data *r_data; - if (!spi_priv->crc_off) { + if (spi_priv->crc7_enabled) { - dev_err(&spi->dev, - "failed cmd response, cmd (%02x), resp (%02x) ", - cmd, r->rsp_cmd_type); + if (!spi_priv->probing_crc) + dev_err(&spi->dev, + "failed cmd, cmd (%02x), resp (%02x) ", + cmd, r->rsp_cmd_type); - if (!spi_priv->crc_off) - memcpy(crc, r_data->crc, 2); + if (!clockless && spi_priv->crc16_enabled) { + crc_recv = (r_data->crc[0] << 8) | r_data->crc[1]; + crc_calc = crc_itu_t(0xffff, r_data->data, 4); + if (crc_recv != crc_calc) { + dev_err(&spi->dev, "%s: bad crc 0x%04x " + "(calculated 0x%04x) ", __func__, + crc_recv, crc_calc); + return -einval; + } + } - if (!spi_priv->crc_off) + if (spi_priv->crc7_enabled) - if (!spi_priv->crc_off) + if (spi_priv->crc7_enabled) - if (!spi_priv->crc_off) + if (spi_priv->crc7_enabled) + u16 crc_recv, crc_calc; - if (!spi_priv->crc_off) + if (spi_priv->crc7_enabled) - if (!spi_priv->crc_off) + if (spi_priv->crc7_enabled) - if (!spi_priv->crc_off) + if (spi_priv->crc7_enabled) - * read crc + * read crc - if (!spi_priv->crc_off && wilc_spi_rx(wilc, crc, 2)) { - dev_err(&spi->dev, - "failed block crc read, bus err "); - return -einval; + if (spi_priv->crc16_enabled) { + if (wilc_spi_rx(wilc, crc, 2)) { + dev_err(&spi->dev, + "failed block crc read, bus err "); + return -einval; + } + crc_recv = (crc[0] << 8) | crc[1]; + crc_calc = crc_itu_t(0xffff, &b[ix], nbytes); + if (crc_recv != crc_calc) { + dev_err(&spi->dev, "%s: bad crc 0x%04x " + "(calculated 0x%04x) ", __func__, + crc_recv, crc_calc); + return -einval; + } + struct wilc_spi *spi_priv = wilc->bus_data; - dev_err(&spi->dev, "failed internal read cmd... "); + if (!spi_priv->probing_crc) + dev_err(&spi->dev, "failed internal read cmd... "); - int ret; + int ret, i; - * todo: we can remove the crc trials if there is a definite - * way to reset + * infer the crc settings that are currently in effect. this + * is necessary because we can't be sure that the chip has + * been reset (e.g, after module unload and reload). - /* the spi to it's initial value. */ - ret = spi_internal_read(wilc, wilc_spi_protocol_offset, ®); - if (ret) { - /* - * read failed. try with crc off. this might happen when module - * is removed but chip isn't reset - */ - spi_priv->crc_off = 1; - dev_err(&spi->dev, - "failed read with crc on, retrying with crc off "); + spi_priv->probing_crc = true; + spi_priv->crc7_enabled = enable_crc7; + spi_priv->crc16_enabled = false; /* don't check crc16 during probing */ + for (i = 0; i < 2; ++i) { - if (ret) { - /* - * read failed with both crc on and off, - * something went bad - */ - dev_err(&spi->dev, "failed internal read protocol "); - return ret; - } + if (ret == 0) + break; + spi_priv->crc7_enabled = !enable_crc7; - if (spi_priv->crc_off == 0) { - /* disable crc checking: */ - reg &= ~(protocol_reg_crc7_mask | protocol_reg_crc16_mask); - - /* set the data packet size: */ - build_bug_on(data_pkt_log_sz < data_pkt_log_sz_min - || data_pkt_log_sz > data_pkt_log_sz_max); - reg &= ~protocol_reg_pkt_sz_mask; - reg |= field_prep(protocol_reg_pkt_sz_mask, - data_pkt_log_sz - data_pkt_log_sz_min); - - ret = spi_internal_write(wilc, wilc_spi_protocol_offset, reg); - if (ret) { - dev_err(&spi->dev, - "[wilc spi %d]: failed internal write reg ", - __line__); - return ret; - } - spi_priv->crc_off = 1; + if (ret) { + dev_err(&spi->dev, "failed with crc7 on and off. "); + return ret; + } + + /* set up the desired crc configuration: */ + reg &= ~(protocol_reg_crc7_mask | protocol_reg_crc16_mask); + if (enable_crc7) + reg |= protocol_reg_crc7_mask; + if (enable_crc16) + reg |= protocol_reg_crc16_mask; + + /* set up the data packet size: */ + build_bug_on(data_pkt_log_sz < data_pkt_log_sz_min + || data_pkt_log_sz > data_pkt_log_sz_max); + reg &= ~protocol_reg_pkt_sz_mask; + reg |= field_prep(protocol_reg_pkt_sz_mask, + data_pkt_log_sz - data_pkt_log_sz_min); + + /* establish the new setup: */ + ret = spi_internal_write(wilc, wilc_spi_protocol_offset, reg); + if (ret) { + dev_err(&spi->dev, + "[wilc spi %d]: failed internal write reg ", + __line__); + return ret; + /* update our state to match new protocol settings: */ + spi_priv->crc7_enabled = enable_crc7; + spi_priv->crc16_enabled = enable_crc16; + + /* re-read to make sure new settings are in effect: */ + spi_internal_read(wilc, wilc_spi_protocol_offset, ®); + + spi_priv->probing_crc = false;
|
Networking
|
c872e7ae056f16e27311fb30d637032cc3b1cb46
|
david mosberger tang
|
drivers
|
net
|
microchip, wilc1000, wireless
|
wilc1000: support chip sleep over spi
|
chip_allow_sleep() only supported wakeup via sdio, which made the driver unusable over spi. this code is a straight forward port from the driver in the linux-at91 repository.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
support chip sleep over spi
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['wilc1000 ']
|
['h', 'c']
| 2
| 58
| 4
|
--- diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c + const struct wilc_hif_func *hif_func = wilc->hif_func; + u32 wakeup_reg, wakeup_bit; + u32 to_host_from_fw_reg, to_host_from_fw_bit; + u32 from_host_to_fw_reg, from_host_to_fw_bit; + u32 trials = 100; + int ret; + + if (wilc->io_type == wilc_hif_sdio) { + wakeup_reg = wilc_sdio_wakeup_reg; + wakeup_bit = wilc_sdio_wakeup_bit; + from_host_to_fw_reg = wilc_sdio_host_to_fw_reg; + from_host_to_fw_bit = wilc_sdio_host_to_fw_bit; + to_host_from_fw_reg = wilc_sdio_fw_to_host_reg; + to_host_from_fw_bit = wilc_sdio_fw_to_host_bit; + } else { + wakeup_reg = wilc_spi_wakeup_reg; + wakeup_bit = wilc_spi_wakeup_bit; + from_host_to_fw_reg = wilc_spi_host_to_fw_reg; + from_host_to_fw_bit = wilc_spi_host_to_fw_bit; + to_host_from_fw_reg = wilc_spi_fw_to_host_reg; + to_host_from_fw_bit = wilc_spi_fw_to_host_bit; + } + + while (trials--) { + ret = hif_func->hif_read_reg(wilc, to_host_from_fw_reg, ®); + if (ret) + return; + if ((reg & to_host_from_fw_bit) == 0) + break; + } + if (!trials) + pr_warn("fw not responding "); - wilc->hif_func->hif_read_reg(wilc, wilc_sdio_wakeup_reg, ®); + /* clear bit 1 */ + ret = hif_func->hif_read_reg(wilc, wakeup_reg, ®); + if (ret) + return; + if (reg & wakeup_bit) { + reg &= ~wakeup_bit; + ret = hif_func->hif_write_reg(wilc, wakeup_reg, reg); + if (ret) + return; + } - wilc->hif_func->hif_write_reg(wilc, wilc_sdio_wakeup_reg, - reg & ~wilc_sdio_wakeup_bit); - wilc->hif_func->hif_write_reg(wilc, wilc_sdio_host_to_fw_reg, 0); + ret = hif_func->hif_read_reg(wilc, from_host_to_fw_reg, ®); + if (ret) + return; + if (reg & from_host_to_fw_bit) { + reg &= ~from_host_to_fw_bit; + ret = hif_func->hif_write_reg(wilc, from_host_to_fw_reg, reg); + if (ret) + return; + + } diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h +#define wilc_spi_host_to_fw_reg 0x0b +#define wilc_spi_host_to_fw_bit bit(0) + +#define wilc_spi_fw_to_host_reg 0x10 +#define wilc_spi_fw_to_host_bit bit(0) +
|
Networking
|
f135a1571a0579bebed625e3af0b1fcae6dff7c5
|
david mosberger tang ajay singh ajay kathat microchip com
|
drivers
|
net
|
microchip, wilc1000, wireless
|
alsa: control - introduce snd_ctl_notify_one() helper
|
this helper is required for the following generic led mute patch. the helper also simplifies some other functions.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add generic led api, which tries to resolve the diversity in the audio led control among the alsa drivers
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'c']
| 2
| 47
| 25
|
--- diff --git a/include/sound/control.h b/include/sound/control.h --- a/include/sound/control.h +++ b/include/sound/control.h +void snd_ctl_notify_one(struct snd_card * card, unsigned int mask, struct snd_kcontrol * kctl, unsigned int ioff); -int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id, - int active); +int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id, int active); diff --git a/sound/core/control.c b/sound/core/control.c --- a/sound/core/control.c +++ b/sound/core/control.c +/** + * snd_ctl_notify_one - send notification to user-space for a control change + * @card: the card to send notification + * @mask: the event mask, sndrv_ctl_event_* + * @kctl: the pointer with the control instance + * @ioff: the additional offset to the control index + * + * this function calls snd_ctl_notify() and does additional jobs + * like led state changes. + */ +void snd_ctl_notify_one(struct snd_card *card, unsigned int mask, + struct snd_kcontrol *kctl, unsigned int ioff) +{ + struct snd_ctl_elem_id id = kctl->id; + + id.index += ioff; + id.numid += ioff; + snd_ctl_notify(card, mask, &id); +} +export_symbol(snd_ctl_notify_one); + - unsigned int count; - id = kcontrol->id; - count = kcontrol->count; - for (idx = 0; idx < count; idx++, id.index++, id.numid++) - snd_ctl_notify(card, sndrv_ctl_event_mask_add, &id); + for (idx = 0; idx < kcontrol->count; idx++) + snd_ctl_notify_one(card, sndrv_ctl_event_mask_add, kcontrol, idx); - struct snd_ctl_elem_id id; - id = kcontrol->id; - for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++) - snd_ctl_notify(card, sndrv_ctl_event_mask_remove, &id); + for (idx = 0; idx < kcontrol->count; idx++) + snd_ctl_notify_one(card, sndrv_ctl_event_mask_remove, kcontrol, idx); - ret = 1; + downgrade_write(&card->controls_rwsem); + snd_ctl_notify_one(card, sndrv_ctl_event_mask_info, kctl, index_offset); + up_read(&card->controls_rwsem); + return 1; + - if (ret > 0) - snd_ctl_notify(card, sndrv_ctl_event_mask_info, id); + down_write(&card->controls_rwsem); - if (kctl == null) + if (kctl == null) { + up_write(&card->controls_rwsem); + } + up_write(&card->controls_rwsem); - if (result < 0) + if (result < 0) { + up_write(&card->controls_rwsem); + } - struct snd_ctl_elem_id id = control->id; - snd_ctl_notify(card, sndrv_ctl_event_mask_value, &id); + downgrade_write(&card->controls_rwsem); + snd_ctl_notify_one(card, sndrv_ctl_event_mask_value, kctl, index_offset); + up_read(&card->controls_rwsem); + } else { + up_write(&card->controls_rwsem); - down_write(&card->controls_rwsem); - up_write(&card->controls_rwsem); - struct snd_ctl_elem_id id; - for (i = 0; i < kctl->count; ++i) { - snd_ctl_build_ioff(&id, kctl, i); - snd_ctl_notify(ue->card, mask, &id); - } + for (i = 0; i < kctl->count; ++i) + snd_ctl_notify_one(ue->card, mask, kctl, i);
|
Audio
|
1fa4445f9adf19a3028ce0e8f375bac75214fc10
|
jaroslav kysela
|
include
|
sound
| |
alsa: control - add layer registration routines
|
the layer registration allows to handle an extra functionality on top of the control api. it can be used for the audio led control for example.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add generic led api, which tries to resolve the diversity in the audio led control among the alsa drivers
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'c']
| 2
| 120
| 2
|
--- diff --git a/include/sound/control.h b/include/sound/control.h --- a/include/sound/control.h +++ b/include/sound/control.h +struct snd_ctl_layer_ops { + struct snd_ctl_layer_ops *next; + const char *module_name; + void (*lregister)(struct snd_card *card); + void (*ldisconnect)(struct snd_card *card); + void (*lnotify)(struct snd_card *card, unsigned int mask, struct snd_kcontrol *kctl, unsigned int ioff); +}; + +int snd_ctl_request_layer(const char *module_name); +void snd_ctl_register_layer(struct snd_ctl_layer_ops *lops); +void snd_ctl_disconnect_layer(struct snd_ctl_layer_ops *lops); + diff --git a/sound/core/control.c b/sound/core/control.c --- a/sound/core/control.c +++ b/sound/core/control.c +static declare_rwsem(snd_ctl_layer_rwsem); +static struct snd_ctl_layer_ops *snd_ctl_layer; + struct snd_ctl_layer_ops *lops; + down_read(&snd_ctl_layer_rwsem); + for (lops = snd_ctl_layer; lops; lops = lops->next) + lops->lnotify(card, mask, kctl, ioff); + up_read(&snd_ctl_layer_rwsem); +/* + * control layers (audio led etc.) + */ + +/** + * snd_ctl_request_layer - request to use the layer + * @module_name: name of the kernel module (null == build-in) + * + * return an error code when the module cannot be loaded. + */ +int snd_ctl_request_layer(const char *module_name) +{ + struct snd_ctl_layer_ops *lops; + + if (module_name == null) + return 0; + down_read(&snd_ctl_layer_rwsem); + for (lops = snd_ctl_layer; lops; lops = lops->next) + if (strcmp(lops->module_name, module_name) == 0) + break; + up_read(&snd_ctl_layer_rwsem); + if (lops) + return 0; + return request_module(module_name); +} +export_symbol_gpl(snd_ctl_request_layer); + +/** + * snd_ctl_register_layer - register new control layer + * @lops: operation structure + * + * the new layer can track all control elements and do additional + * operations on top (like audio led handling). + */ +void snd_ctl_register_layer(struct snd_ctl_layer_ops *lops) +{ + struct snd_card *card; + int card_number; + + down_write(&snd_ctl_layer_rwsem); + lops->next = snd_ctl_layer; + snd_ctl_layer = lops; + up_write(&snd_ctl_layer_rwsem); + for (card_number = 0; card_number < sndrv_cards; card_number++) { + card = snd_card_ref(card_number); + if (card) { + down_read(&card->controls_rwsem); + lops->lregister(card); + up_read(&card->controls_rwsem); + snd_card_unref(card); + } + } +} +export_symbol_gpl(snd_ctl_register_layer); + +/** + * snd_ctl_disconnect_layer - disconnect control layer + * @lops: operation structure + * + * it is expected that the information about tracked cards + * is freed before this call (the disconnect callback is + * not called here). + */ +void snd_ctl_disconnect_layer(struct snd_ctl_layer_ops *lops) +{ + struct snd_ctl_layer_ops *lops2, *prev_lops2; + + down_write(&snd_ctl_layer_rwsem); + for (lops2 = snd_ctl_layer, prev_lops2 = null; lops2; lops2 = lops2->next) + if (lops2 == lops) { + if (!prev_lops2) + snd_ctl_layer = lops->next; + else + prev_lops2->next = lops->next; + break; + } + up_write(&snd_ctl_layer_rwsem); +} +export_symbol_gpl(snd_ctl_disconnect_layer); + + struct snd_ctl_layer_ops *lops; + int err; - return snd_register_device(sndrv_device_type_control, card, -1, - &snd_ctl_f_ops, card, &card->ctl_dev); + err = snd_register_device(sndrv_device_type_control, card, -1, + &snd_ctl_f_ops, card, &card->ctl_dev); + if (err < 0) + return err; + down_read(&card->controls_rwsem); + down_read(&snd_ctl_layer_rwsem); + for (lops = snd_ctl_layer; lops; lops = lops->next) + lops->lregister(card); + up_read(&snd_ctl_layer_rwsem); + up_read(&card->controls_rwsem); + return 0; + struct snd_ctl_layer_ops *lops; + down_read(&card->controls_rwsem); + down_read(&snd_ctl_layer_rwsem); + for (lops = snd_ctl_layer; lops; lops = lops->next) + lops->ldisconnect(card); + up_read(&snd_ctl_layer_rwsem); + up_read(&card->controls_rwsem); +
|
Audio
|
3f0638a0333bfdd0549985aa620f2ab69737af47
|
jaroslav kysela
|
include
|
sound
| |
alsa: control - add generic led trigger module as the new control layer
|
the recent laptops have usually two leds assigned to reflect the speaker and microphone mute state. this implementation adds a tiny layer on top of the control api which calculates the state for those leds using the driver callbacks.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add generic led api, which tries to resolve the diversity in the audio led control among the alsa drivers
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'kconfig', 'c', 'makefile']
| 5
| 307
| 2
|
--- diff --git a/include/sound/control.h b/include/sound/control.h --- a/include/sound/control.h +++ b/include/sound/control.h -#define sndrv_ctl_elem_access_skip_check (1 << 27) +#define sndrv_ctl_elem_access_skip_check (1 << 24) +/* kernel only - led bits */ +#define sndrv_ctl_elem_access_led_shift 25 +#define sndrv_ctl_elem_access_led_mask (7<<25) /* kernel three bits - led group */ +#define sndrv_ctl_elem_access_spk_led (1<<25) /* kernel speaker (output) led flag */ +#define sndrv_ctl_elem_access_mic_led (2<<25) /* kernel microphone (input) led flag */ + +/* + * control led trigger layer + */ +#define snd_ctl_layer_module_led "snd-ctl-led" + +#if is_module(config_snd_ctl_led) +static inline int snd_ctl_led_request(void) { return snd_ctl_request_layer(snd_ctl_layer_module_led); } +#else +static inline int snd_ctl_led_request(void) { return 0; } +#endif + diff --git a/sound/core/kconfig b/sound/core/kconfig --- a/sound/core/kconfig +++ b/sound/core/kconfig +config snd_ctl_led + tristate + select new_leds if snd_ctl_led + select leds_triggers if snd_ctl_led + select leds_trigger_audio if snd_ctl_led + diff --git a/sound/core/makefile b/sound/core/makefile --- a/sound/core/makefile +++ b/sound/core/makefile +snd-ctl-led-objs := control_led.o +obj-$(config_snd_ctl_led) += snd-ctl-led.o diff --git a/sound/core/control.c b/sound/core/control.c --- a/sound/core/control.c +++ b/sound/core/control.c + sndrv_ctl_elem_access_led_mask | - info.access &= ~sndrv_ctl_elem_access_skip_check; + info.access &= ~(sndrv_ctl_elem_access_skip_check| + sndrv_ctl_elem_access_led_mask); diff --git a/sound/core/control_led.c b/sound/core/control_led.c --- /dev/null +++ b/sound/core/control_led.c +// spdx-license-identifier: gpl-2.0-or-later +/* + * led state routines for driver control interface + * copyright (c) 2021 by jaroslav kysela <perex@perex.cz> + */ + +#include <linux/slab.h> +#include <linux/module.h> +#include <linux/leds.h> +#include <sound/core.h> +#include <sound/control.h> + +module_author("jaroslav kysela <perex@perex.cz>"); +module_description("alsa control interface to led trigger code."); +module_license("gpl"); + +#define max_led (((sndrv_ctl_elem_access_mic_led - sndrv_ctl_elem_access_spk_led) \ + >> sndrv_ctl_elem_access_led_shift) + 1) + +struct snd_ctl_led { + struct list_head list; + struct snd_card *card; + unsigned int access; + struct snd_kcontrol *kctl; + unsigned int index_offset; +}; + +static define_mutex(snd_ctl_led_mutex); +static struct list_head snd_ctl_led_controls[max_led]; +static bool snd_ctl_led_card_valid[sndrv_cards]; + +#define update_route(route, cb) \ + do { \ + int route2 = (cb); \ + if (route2 >= 0) \ + route = route < 0 ? route2 : (route | route2); \ + } while (0) + +static inline unsigned int access_to_group(unsigned int access) +{ + return ((access & sndrv_ctl_elem_access_led_mask) >> + sndrv_ctl_elem_access_led_shift) - 1; +} + +static inline unsigned int group_to_access(unsigned int group) +{ + return (group + 1) << sndrv_ctl_elem_access_led_shift; +} + +static struct list_head *snd_ctl_led_controls_by_access(unsigned int access) +{ + unsigned int group = access_to_group(access); + if (group >= max_led) + return null; + return &snd_ctl_led_controls[group]; +} + +static int snd_ctl_led_get(struct snd_ctl_led *lctl) +{ + struct snd_kcontrol *kctl = lctl->kctl; + struct snd_ctl_elem_info info; + struct snd_ctl_elem_value value; + unsigned int i; + int result; + + memset(&info, 0, sizeof(info)); + info.id = kctl->id; + info.id.index += lctl->index_offset; + info.id.numid += lctl->index_offset; + result = kctl->info(kctl, &info); + if (result < 0) + return -1; + memset(&value, 0, sizeof(value)); + value.id = info.id; + result = kctl->get(kctl, &value); + if (result < 0) + return -1; + if (info.type == sndrv_ctl_elem_type_boolean || + info.type == sndrv_ctl_elem_type_integer) { + for (i = 0; i < info.count; i++) + if (value.value.integer.value[i] != info.value.integer.min) + return 1; + } else if (info.type == sndrv_ctl_elem_type_integer64) { + for (i = 0; i < info.count; i++) + if (value.value.integer64.value[i] != info.value.integer64.min) + return 1; + } + return 0; +} + +static void snd_ctl_led_set_state(struct snd_card *card, unsigned int access, + struct snd_kcontrol *kctl, unsigned int ioff) +{ + struct list_head *controls; + struct snd_ctl_led *lctl; + enum led_audio led_trigger_type; + int route; + bool found; + + controls = snd_ctl_led_controls_by_access(access); + if (!controls) + return; + if (access == sndrv_ctl_elem_access_spk_led) { + led_trigger_type = led_audio_mute; + } else if (access == sndrv_ctl_elem_access_mic_led) { + led_trigger_type = led_audio_micmute; + } else { + return; + } + route = -1; + found = false; + mutex_lock(&snd_ctl_led_mutex); + /* the card may not be registered (active) at this point */ + if (card && !snd_ctl_led_card_valid[card->number]) { + mutex_unlock(&snd_ctl_led_mutex); + return; + } + list_for_each_entry(lctl, controls, list) { + if (lctl->kctl == kctl && lctl->index_offset == ioff) + found = true; + update_route(route, snd_ctl_led_get(lctl)); + } + if (!found && kctl && card) { + lctl = kzalloc(sizeof(*lctl), gfp_kernel); + if (lctl) { + lctl->card = card; + lctl->access = access; + lctl->kctl = kctl; + lctl->index_offset = ioff; + list_add(&lctl->list, controls); + update_route(route, snd_ctl_led_get(lctl)); + } + } + mutex_unlock(&snd_ctl_led_mutex); + if (route >= 0) + ledtrig_audio_set(led_trigger_type, route ? led_off : led_on); +} + +static struct snd_ctl_led *snd_ctl_led_find(struct snd_kcontrol *kctl, unsigned int ioff) +{ + struct list_head *controls; + struct snd_ctl_led *lctl; + unsigned int group; + + for (group = 0; group < max_led; group++) { + controls = &snd_ctl_led_controls[group]; + list_for_each_entry(lctl, controls, list) + if (lctl->kctl == kctl && lctl->index_offset == ioff) + return lctl; + } + return null; +} + +static unsigned int snd_ctl_led_remove(struct snd_kcontrol *kctl, unsigned int ioff, + unsigned int access) +{ + struct snd_ctl_led *lctl; + unsigned int ret = 0; + + mutex_lock(&snd_ctl_led_mutex); + lctl = snd_ctl_led_find(kctl, ioff); + if (lctl && (access == 0 || access != lctl->access)) { + ret = lctl->access; + list_del(&lctl->list); + kfree(lctl); + } + mutex_unlock(&snd_ctl_led_mutex); + return ret; +} + +static void snd_ctl_led_notify(struct snd_card *card, unsigned int mask, + struct snd_kcontrol *kctl, unsigned int ioff) +{ + struct snd_kcontrol_volatile *vd; + unsigned int access, access2; + + if (mask == sndrv_ctl_event_mask_remove) { + access = snd_ctl_led_remove(kctl, ioff, 0); + if (access) + snd_ctl_led_set_state(card, access, null, 0); + } else if (mask & sndrv_ctl_event_mask_info) { + vd = &kctl->vd[ioff]; + access = vd->access & sndrv_ctl_elem_access_led_mask; + access2 = snd_ctl_led_remove(kctl, ioff, access); + if (access2) + snd_ctl_led_set_state(card, access2, null, 0); + if (access) + snd_ctl_led_set_state(card, access, kctl, ioff); + } else if ((mask & (sndrv_ctl_event_mask_add | + sndrv_ctl_event_mask_value)) != 0) { + vd = &kctl->vd[ioff]; + access = vd->access & sndrv_ctl_elem_access_led_mask; + if (access) + snd_ctl_led_set_state(card, access, kctl, ioff); + } +} + +static void snd_ctl_led_refresh(void) +{ + unsigned int group; + + for (group = 0; group < max_led; group++) + snd_ctl_led_set_state(null, group_to_access(group), null, 0); +} + +static void snd_ctl_led_clean(struct snd_card *card) +{ + unsigned int group; + struct list_head *controls; + struct snd_ctl_led *lctl; + + for (group = 0; group < max_led; group++) { + controls = &snd_ctl_led_controls[group]; +repeat: + list_for_each_entry(lctl, controls, list) + if (!card || lctl->card == card) { + list_del(&lctl->list); + kfree(lctl); + goto repeat; + } + } +} + +static void snd_ctl_led_register(struct snd_card *card) +{ + struct snd_kcontrol *kctl; + unsigned int ioff; + + if (snd_bug_on(card->number < 0 || + card->number >= array_size(snd_ctl_led_card_valid))) + return; + mutex_lock(&snd_ctl_led_mutex); + snd_ctl_led_card_valid[card->number] = true; + mutex_unlock(&snd_ctl_led_mutex); + /* the register callback is already called with held card->controls_rwsem */ + list_for_each_entry(kctl, &card->controls, list) + for (ioff = 0; ioff < kctl->count; ioff++) + snd_ctl_led_notify(card, sndrv_ctl_event_mask_value, kctl, ioff); + snd_ctl_led_refresh(); +} + +static void snd_ctl_led_disconnect(struct snd_card *card) +{ + mutex_lock(&snd_ctl_led_mutex); + snd_ctl_led_card_valid[card->number] = false; + snd_ctl_led_clean(card); + mutex_unlock(&snd_ctl_led_mutex); + snd_ctl_led_refresh(); +} + +/* + * control layer registration + */ +static struct snd_ctl_layer_ops snd_ctl_led_lops = { + .module_name = snd_ctl_layer_module_led, + .lregister = snd_ctl_led_register, + .ldisconnect = snd_ctl_led_disconnect, + .lnotify = snd_ctl_led_notify, +}; + +static int __init snd_ctl_led_init(void) +{ + unsigned int group; + + for (group = 0; group < max_led; group++) + init_list_head(&snd_ctl_led_controls[group]); + snd_ctl_register_layer(&snd_ctl_led_lops); + return 0; +} + +static void __exit snd_ctl_led_exit(void) +{ + snd_ctl_disconnect_layer(&snd_ctl_led_lops); + snd_ctl_led_clean(null); +} + +module_init(snd_ctl_led_init) +module_exit(snd_ctl_led_exit)
|
Audio
|
22d8de62f11b287b279f1d4473a78c7d5e53e7bc
|
jaroslav kysela
|
include
|
sound
| |
alsa: hda - remove the custom implementation for the audio led trigger
|
with the new snd-ctl-led module, we have a generic way to trigger audio leds based on the sound control changes.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add generic led api, which tries to resolve the diversity in the audio led control among the alsa drivers
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'kconfig', 'c']
| 9
| 45
| 235
|
--- diff --git a/sound/pci/hda/kconfig b/sound/pci/hda/kconfig --- a/sound/pci/hda/kconfig +++ b/sound/pci/hda/kconfig - select new_leds if snd_hda_generic_leds + select snd_ctl_led if snd_hda_generic_leds - select leds_triggers if snd_hda_generic_leds - select leds_trigger_audio if snd_hda_generic_leds diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c - struct snd_kcontrol **ctl_ret) + unsigned int access, struct snd_kcontrol **ctl_ret) + kctl->vd[0].access |= access; -/* - * mute-led control using vmaster - */ -static int vmaster_mute_mode_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - static const char * const texts[] = { - "on", "off", "follow master" - }; - - return snd_ctl_enum_info(uinfo, 1, 3, texts); -} - -static int vmaster_mute_mode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct hda_vmaster_mute_hook *hook = snd_kcontrol_chip(kcontrol); - ucontrol->value.enumerated.item[0] = hook->mute_mode; - return 0; -} - -static int vmaster_mute_mode_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct hda_vmaster_mute_hook *hook = snd_kcontrol_chip(kcontrol); - unsigned int old_mode = hook->mute_mode; - - hook->mute_mode = ucontrol->value.enumerated.item[0]; - if (hook->mute_mode > hda_vmute_follow_master) - hook->mute_mode = hda_vmute_follow_master; - if (old_mode == hook->mute_mode) - return 0; - snd_hda_sync_vmaster_hook(hook); - return 1; -} - -static const struct snd_kcontrol_new vmaster_mute_mode = { - .iface = sndrv_ctl_elem_iface_mixer, - .name = "mute-led mode", - .info = vmaster_mute_mode_info, - .get = vmaster_mute_mode_get, - .put = vmaster_mute_mode_put, -}; - - if (hook->mute_mode != hda_vmute_follow_master) - enabled = hook->mute_mode; - * snd_hda_add_vmaster_hook - add a vmaster hook for mute-led + * snd_hda_add_vmaster_hook - add a vmaster hw specific hook - * @expose_enum_ctl: flag to create an enum ctl - * add a mute-led hook with the given vmaster switch kctl. - * when @expose_enum_ctl is set, "mute-led mode" control is automatically - * created and associated with the given hook. + * add a hw specific hook (like eapd) with the given vmaster switch kctl. - struct hda_vmaster_mute_hook *hook, - bool expose_enum_ctl) + struct hda_vmaster_mute_hook *hook) - struct snd_kcontrol *kctl; - - hook->mute_mode = hda_vmute_follow_master; - if (!expose_enum_ctl) - return 0; - kctl = snd_ctl_new1(&vmaster_mute_mode, hook); - if (!kctl) - return -enomem; - return snd_hda_ctl_add(codec, 0, kctl); + return 0; diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c + if (knew->access == 0) + knew->access = sndrv_ctl_elem_access_readwrite; - if (is_switch) + if (is_switch) { + if (spec->mic_mute_led) + knew->access |= sndrv_ctl_elem_access_mic_led; + } - if (is_switch) + if (is_switch) { + if (spec->mic_mute_led) + knew->access |= sndrv_ctl_elem_access_mic_led; + } + if (spec->mic_mute_led) + knew->access |= sndrv_ctl_elem_access_mic_led; -static void vmaster_update_mute_led(void *private_data, int enabled) -{ - ledtrig_audio_set(led_audio_mute, enabled ? led_off : led_on); -} - - spec->vmaster_mute.hook = vmaster_update_mute_led; - spec->vmaster_mute_enum = 1; + spec->vmaster_mute_led = 1; -/* - * mic mute led hook helpers - */ -enum { - micmute_led_on, - micmute_led_off, - micmute_led_follow_capture, - micmute_led_follow_mute, -}; - -static void call_micmute_led_update(struct hda_codec *codec) -{ - struct hda_gen_spec *spec = codec->spec; - unsigned int val; - - switch (spec->micmute_led.led_mode) { - case micmute_led_on: - val = 1; - break; - case micmute_led_off: - val = 0; - break; - case micmute_led_follow_capture: - val = !!spec->micmute_led.capture; - break; - case micmute_led_follow_mute: - default: - val = !spec->micmute_led.capture; - break; - } - - if (val == spec->micmute_led.led_value) - return; - spec->micmute_led.led_value = val; - ledtrig_audio_set(led_audio_micmute, - spec->micmute_led.led_value ? led_on : led_off); -} - -static void update_micmute_led(struct hda_codec *codec, - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct hda_gen_spec *spec = codec->spec; - unsigned int mask; - - if (spec->micmute_led.old_hook) - spec->micmute_led.old_hook(codec, kcontrol, ucontrol); - - if (!ucontrol) - return; - mask = 1u << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); - if (!strcmp("capture switch", ucontrol->id.name)) { - /* todo: how do i verify if it's a mono or stereo here? */ - if (ucontrol->value.integer.value[0] || - ucontrol->value.integer.value[1]) - spec->micmute_led.capture |= mask; - else - spec->micmute_led.capture &= ~mask; - call_micmute_led_update(codec); - } -} - -static int micmute_led_mode_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - static const char * const texts[] = { - "on", "off", "follow capture", "follow mute", - }; - - return snd_ctl_enum_info(uinfo, 1, array_size(texts), texts); -} - -static int micmute_led_mode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct hda_codec *codec = snd_kcontrol_chip(kcontrol); - struct hda_gen_spec *spec = codec->spec; - - ucontrol->value.enumerated.item[0] = spec->micmute_led.led_mode; - return 0; -} - -static int micmute_led_mode_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct hda_codec *codec = snd_kcontrol_chip(kcontrol); - struct hda_gen_spec *spec = codec->spec; - unsigned int mode; - - mode = ucontrol->value.enumerated.item[0]; - if (mode > micmute_led_follow_mute) - mode = micmute_led_follow_mute; - if (mode == spec->micmute_led.led_mode) - return 0; - spec->micmute_led.led_mode = mode; - call_micmute_led_update(codec); - return 1; -} - -static const struct snd_kcontrol_new micmute_led_mode_ctl = { - .iface = sndrv_ctl_elem_iface_mixer, - .name = "mic mute-led mode", - .info = micmute_led_mode_info, - .get = micmute_led_mode_get, - .put = micmute_led_mode_put, -}; - -/* set up the capture sync hook for controlling the mic-mute led */ -static int add_micmute_led_hook(struct hda_codec *codec) -{ - struct hda_gen_spec *spec = codec->spec; - - spec->micmute_led.led_mode = micmute_led_follow_mute; - spec->micmute_led.capture = 0; - spec->micmute_led.led_value = -1; - spec->micmute_led.old_hook = spec->cap_sync_hook; - spec->cap_sync_hook = update_micmute_led; - if (!snd_hda_gen_add_kctl(spec, null, &micmute_led_mode_ctl)) - return -enomem; - return 0; -} - + struct hda_gen_spec *spec = codec->spec; - return add_micmute_led_hook(codec); + spec->mic_mute_led = 1; + return 0; + if (spec->vmaster_mute_led || spec->mic_mute_led) + snd_ctl_led_request(); + - "playback volume"); + "playback volume", 0); - "playback switch", - true, &spec->vmaster_mute.sw_kctl); + "playback switch", true, + spec->vmaster_mute_led ? + sndrv_ctl_elem_access_spk_led : 0, + &spec->vmaster_mute.sw_kctl); - snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, - spec->vmaster_mute_enum); + snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute); diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h -struct hda_micmute_hook { - unsigned int led_mode; - unsigned int capture; - unsigned int led_value; - void (*old_hook)(struct hda_codec *codec, - struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -}; - - unsigned int vmaster_mute_enum:1; /* add vmaster mute mode enum */ + unsigned int vmaster_mute_led:1; /* add spk-led flag to vmaster mute switch */ + unsigned int mic_mute_led:1; /* add mic-led flag to capture mute switch */ - /* mic mute led hook; called via cap_sync_hook */ - struct hda_micmute_hook micmute_led; - diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h - struct snd_kcontrol **ctl_ret); -#define snd_hda_add_vmaster(codec, name, tlv, followers, suffix) \ - __snd_hda_add_vmaster(codec, name, tlv, followers, suffix, true, null) + unsigned int access, struct snd_kcontrol **ctl_ret); +#define snd_hda_add_vmaster(codec, name, tlv, followers, suffix, access) \ + __snd_hda_add_vmaster(codec, name, tlv, followers, suffix, true, access, null) -enum { - hda_vmute_off, - hda_vmute_on, - hda_vmute_follow_master, -}; - - unsigned int mute_mode; /* hda_vmute_xxx */ - struct hda_vmaster_mute_hook *hook, - bool expose_enum_ctl); + struct hda_vmaster_mute_hook *hook); diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c - "playback volume"); + "playback volume", 0); - true, &spec->vmaster_mute.sw_kctl); + true, 0, &spec->vmaster_mute.sw_kctl); diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c - if (action == hda_fixup_act_probe) + if (action == hda_fixup_act_pre_probe) diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c + if (spec->gpio_led) + snd_hda_gen_add_mute_led_cdev(codec, stac_vmaster_hook); + - if (spec->gpio_led) - snd_hda_gen_add_mute_led_cdev(codec, stac_vmaster_hook); - diff --git a/sound/pci/hda/thinkpad_helper.c b/sound/pci/hda/thinkpad_helper.c --- a/sound/pci/hda/thinkpad_helper.c +++ b/sound/pci/hda/thinkpad_helper.c - if (action == hda_fixup_act_probe) { + if (action == hda_fixup_act_pre_probe) {
|
Audio
|
e65bf99718b538c2f34e9444dfe1087789b58f94
|
jaroslav kysela
|
sound
|
pci
|
hda
|
alsa: control - add sysfs support to the led trigger module
|
create sysfs/devices/virtual/sound/ctl-led tree (with sysfs/class/sound/ctl-led symlink).
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add generic led api, which tries to resolve the diversity in the audio led control among the alsa drivers
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['c']
| 1
| 163
| 29
|
+-- mode +-- brightness +-- mode +-- brightness - follow mute - follow moute (inverted to follow mute) - off - on --- diff --git a/sound/core/control_led.c b/sound/core/control_led.c --- a/sound/core/control_led.c +++ b/sound/core/control_led.c +enum snd_ctl_led_mode { + mode_follow_mute = 0, + mode_follow_route, + mode_off, + mode_on, +}; + + struct device dev; + struct list_head controls; + const char *name; + unsigned int group; + enum led_audio trigger_type; + enum snd_ctl_led_mode mode; +}; + +struct snd_ctl_led_ctl { -static struct list_head snd_ctl_led_controls[max_led]; +static struct snd_ctl_led snd_ctl_leds[max_led] = { + { + .name = "speaker", + .group = (sndrv_ctl_elem_access_spk_led >> sndrv_ctl_elem_access_led_shift) - 1, + .trigger_type = led_audio_mute, + .mode = mode_follow_mute, + }, + { + .name = "mic", + .group = (sndrv_ctl_elem_access_mic_led >> sndrv_ctl_elem_access_led_shift) - 1, + .trigger_type = led_audio_micmute, + .mode = mode_follow_mute, + }, +}; -static struct list_head *snd_ctl_led_controls_by_access(unsigned int access) +static struct snd_ctl_led *snd_ctl_led_get_by_access(unsigned int access) - return &snd_ctl_led_controls[group]; + return &snd_ctl_leds[group]; -static int snd_ctl_led_get(struct snd_ctl_led *lctl) +static int snd_ctl_led_get(struct snd_ctl_led_ctl *lctl) - struct list_head *controls; - struct snd_ctl_led *lctl; - enum led_audio led_trigger_type; + struct snd_ctl_led *led; + struct snd_ctl_led_ctl *lctl; - controls = snd_ctl_led_controls_by_access(access); - if (!controls) + led = snd_ctl_led_get_by_access(access); + if (!led) - if (access == sndrv_ctl_elem_access_spk_led) { - led_trigger_type = led_audio_mute; - } else if (access == sndrv_ctl_elem_access_mic_led) { - led_trigger_type = led_audio_micmute; - } else { - return; - } - list_for_each_entry(lctl, controls, list) { + list_for_each_entry(lctl, &led->controls, list) { - list_add(&lctl->list, controls); + list_add(&lctl->list, &led->controls); + switch (led->mode) { + case mode_off: route = 1; break; + case mode_on: route = 0; break; + case mode_follow_route: if (route >= 0) route ^= 1; break; + case mode_follow_mute: /* noop */ break; + } - ledtrig_audio_set(led_trigger_type, route ? led_off : led_on); + ledtrig_audio_set(led->trigger_type, route ? led_off : led_on); -static struct snd_ctl_led *snd_ctl_led_find(struct snd_kcontrol *kctl, unsigned int ioff) +static struct snd_ctl_led_ctl *snd_ctl_led_find(struct snd_kcontrol *kctl, unsigned int ioff) - struct snd_ctl_led *lctl; + struct snd_ctl_led_ctl *lctl; - controls = &snd_ctl_led_controls[group]; + controls = &snd_ctl_leds[group].controls; - struct snd_ctl_led *lctl; + struct snd_ctl_led_ctl *lctl; - struct list_head *controls; - struct snd_ctl_led *lctl; + struct snd_ctl_led *led; + struct snd_ctl_led_ctl *lctl; - controls = &snd_ctl_led_controls[group]; + led = &snd_ctl_leds[group]; - list_for_each_entry(lctl, controls, list) + list_for_each_entry(lctl, &led->controls, list) +/* + * sysfs + */ + +static ssize_t show_mode(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev); + const char *str; + + switch (led->mode) { + case mode_follow_mute: str = "follow-mute"; break; + case mode_follow_route: str = "follow-route"; break; + case mode_on: str = "on"; break; + case mode_off: str = "off"; break; + } + return sprintf(buf, "%s ", str); +} + +static ssize_t store_mode(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev); + char _buf[16]; + size_t l = min(count, sizeof(_buf) - 1) + 1; + enum snd_ctl_led_mode mode; + + memcpy(_buf, buf, l); + _buf[l] = ''; + if (strstr(_buf, "mute")) + mode = mode_follow_mute; + else if (strstr(_buf, "route")) + mode = mode_follow_route; + else if (strncmp(_buf, "off", 3) == 0 || strncmp(_buf, "0", 1) == 0) + mode = mode_off; + else if (strncmp(_buf, "on", 2) == 0 || strncmp(_buf, "1", 1) == 0) + mode = mode_on; + else + return count; + + mutex_lock(&snd_ctl_led_mutex); + led->mode = mode; + mutex_unlock(&snd_ctl_led_mutex); + + snd_ctl_led_set_state(null, group_to_access(led->group), null, 0); + return count; +} + +static ssize_t show_brightness(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev); + + return sprintf(buf, "%u ", ledtrig_audio_get(led->trigger_type)); +} + +static device_attr(mode, 0644, show_mode, store_mode); +static device_attr(brightness, 0444, show_brightness, null); + +static struct attribute *snd_ctl_led_dev_attrs[] = { + &dev_attr_mode.attr, + &dev_attr_brightness.attr, + null, +}; + +static const struct attribute_group snd_ctl_led_dev_attr_group = { + .attrs = snd_ctl_led_dev_attrs, +}; + +static const struct attribute_group *snd_ctl_led_dev_attr_groups[] = { + &snd_ctl_led_dev_attr_group, + null, +}; + +static struct device snd_ctl_led_dev; + + struct snd_ctl_led *led; - for (group = 0; group < max_led; group++) - init_list_head(&snd_ctl_led_controls[group]); + device_initialize(&snd_ctl_led_dev); + snd_ctl_led_dev.class = sound_class; + dev_set_name(&snd_ctl_led_dev, "ctl-led"); + if (device_add(&snd_ctl_led_dev)) { + put_device(&snd_ctl_led_dev); + return -enomem; + } + for (group = 0; group < max_led; group++) { + led = &snd_ctl_leds[group]; + init_list_head(&led->controls); + device_initialize(&led->dev); + led->dev.parent = &snd_ctl_led_dev; + led->dev.groups = snd_ctl_led_dev_attr_groups; + dev_set_name(&led->dev, led->name); + if (device_add(&led->dev)) { + put_device(&led->dev); + for (; group > 0; group--) { + led = &snd_ctl_leds[group]; + device_del(&led->dev); + } + device_del(&snd_ctl_led_dev); + return -enomem; + } + } + struct snd_ctl_led *led; + unsigned int group; + + for (group = 0; group < max_led; group++) { + led = &snd_ctl_leds[group]; + device_del(&led->dev); + } + device_del(&snd_ctl_led_dev);
|
Audio
|
cb17fe0045aaa74d1ce12c0ad0058a62a1ce0401
|
jaroslav kysela
|
sound
|
core
| |
alsa: led control - add sysfs kcontrol led marking layer
|
we need to manage the kcontrol entries association for the led trigger from the user space. this patch adds a layer to the sysfs tree like:
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add generic led api, which tries to resolve the diversity in the audio led control among the alsa drivers
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['c']
| 1
| 362
| 4
|
+ card0 + card1 + attach - amixer style id is accepted and easy strings for numid and - reset all associated kcontrol entries - list associated kcontrol entries (numid values only) --- diff --git a/sound/core/control_led.c b/sound/core/control_led.c --- a/sound/core/control_led.c +++ b/sound/core/control_led.c +struct snd_ctl_led_card { + struct device dev; + int number; + struct snd_ctl_led *led; +}; + + struct snd_ctl_led_card *cards[sndrv_cards]; +static void snd_ctl_led_sysfs_add(struct snd_card *card); +static void snd_ctl_led_sysfs_remove(struct snd_card *card); + +static int snd_ctl_led_set_id(int card_number, struct snd_ctl_elem_id *id, + unsigned int group, bool set) +{ + struct snd_card *card; + struct snd_kcontrol *kctl; + struct snd_kcontrol_volatile *vd; + unsigned int ioff, access, new_access; + int err = 0; + + card = snd_card_ref(card_number); + if (card) { + down_write(&card->controls_rwsem); + kctl = snd_ctl_find_id(card, id); + if (kctl) { + ioff = snd_ctl_get_ioff(kctl, id); + vd = &kctl->vd[ioff]; + access = vd->access & sndrv_ctl_elem_access_led_mask; + if (access != 0 && access != group_to_access(group)) { + err = -exdev; + goto unlock; + } + new_access = vd->access & ~sndrv_ctl_elem_access_led_mask; + if (set) + new_access |= group_to_access(group); + if (new_access != vd->access) { + vd->access = new_access; + snd_ctl_led_notify(card, sndrv_ctl_event_mask_info, kctl, ioff); + } + } else { + err = -enoent; + } +unlock: + up_write(&card->controls_rwsem); + snd_card_unref(card); + } else { + err = -enxio; + } + return err; +} + +static void snd_ctl_led_ctl_destroy(struct snd_ctl_led_ctl *lctl) +{ + list_del(&lctl->list); + kfree(lctl); +} + - list_del(&lctl->list); - kfree(lctl); + snd_ctl_led_ctl_destroy(lctl); +static int snd_ctl_led_reset(int card_number, unsigned int group) +{ + struct snd_card *card; + struct snd_ctl_led *led; + struct snd_ctl_led_ctl *lctl; + struct snd_kcontrol_volatile *vd; + bool change = false; + + card = snd_card_ref(card_number); + if (!card) + return -enxio; + + mutex_lock(&snd_ctl_led_mutex); + if (!snd_ctl_led_card_valid[card_number]) { + mutex_unlock(&snd_ctl_led_mutex); + snd_card_unref(card); + return -enxio; + } + led = &snd_ctl_leds[group]; +repeat: + list_for_each_entry(lctl, &led->controls, list) + if (lctl->card == card) { + vd = &lctl->kctl->vd[lctl->index_offset]; + vd->access &= ~group_to_access(group); + snd_ctl_led_ctl_destroy(lctl); + change = true; + goto repeat; + } + mutex_unlock(&snd_ctl_led_mutex); + if (change) + snd_ctl_led_set_state(null, group_to_access(group), null, 0); + snd_card_unref(card); + return 0; +} + + snd_ctl_led_sysfs_add(card); + snd_ctl_led_sysfs_remove(card); +static char *find_eos(char *s) +{ + while (*s && *s != ',') + s++; + if (*s) + s++; + return s; +} + +static char *parse_uint(char *s, unsigned int *val) +{ + unsigned long long res; + if (kstrtoull(s, 10, &res)) + res = 0; + *val = res; + return find_eos(s); +} + +static char *parse_string(char *s, char *val, size_t val_size) +{ + if (*s == '"' || *s == ''') { + char c = *s; + s++; + while (*s && *s != c) { + if (val_size > 1) { + *val++ = *s; + val_size--; + } + s++; + } + } else { + while (*s && *s != ',') { + if (val_size > 1) { + *val++ = *s; + val_size--; + } + s++; + } + } + *val = ''; + if (*s) + s++; + return s; +} + +static char *parse_iface(char *s, unsigned int *val) +{ + if (!strncasecmp(s, "card", 4)) + *val = sndrv_ctl_elem_iface_card; + else if (!strncasecmp(s, "mixer", 5)) + *val = sndrv_ctl_elem_iface_mixer; + return find_eos(s); +} + +/* + * these types of input strings are accepted: + * + * unsigned integer - numid (equivaled to numid=uint) + * string - basic mixer name (equivalent to iface=mixer,name=str) + * numid=uint + * [iface=mixer,][device=uint,][subdevice=uint,]name=str[,index=uint] + */ +static ssize_t set_led_id(struct snd_ctl_led_card *led_card, const char *buf, size_t count, + bool attach) +{ + char buf2[256], *s; + size_t len = max(sizeof(s) - 1, count); + struct snd_ctl_elem_id id; + int err; + + strncpy(buf2, buf, len); + buf2[len] = ''; + memset(&id, 0, sizeof(id)); + id.iface = sndrv_ctl_elem_iface_mixer; + s = buf2; + while (*s) { + if (!strncasecmp(s, "numid=", 6)) { + s = parse_uint(s + 6, &id.numid); + } else if (!strncasecmp(s, "iface=", 6)) { + s = parse_iface(s + 6, &id.iface); + } else if (!strncasecmp(s, "device=", 7)) { + s = parse_uint(s + 7, &id.device); + } else if (!strncasecmp(s, "subdevice=", 10)) { + s = parse_uint(s + 10, &id.subdevice); + } else if (!strncasecmp(s, "name=", 5)) { + s = parse_string(s + 5, id.name, sizeof(id.name)); + } else if (!strncasecmp(s, "index=", 6)) { + s = parse_uint(s + 6, &id.index); + } else if (s == buf2) { + while (*s) { + if (*s < '0' || *s > '9') + break; + s++; + } + if (*s == '') + parse_uint(buf2, &id.numid); + else { + for (; *s >= ' '; s++); + *s = ''; + strlcpy(id.name, buf2, sizeof(id.name)); + } + break; + } + if (*s == ',') + s++; + } + + err = snd_ctl_led_set_id(led_card->number, &id, led_card->led->group, attach); + if (err < 0) + return err; + + return count; +} + +static ssize_t parse_attach(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); + return set_led_id(led_card, buf, count, true); +} + +static ssize_t parse_detach(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); + return set_led_id(led_card, buf, count, false); +} + +static ssize_t ctl_reset(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); + int err; + + if (count > 0 && buf[0] == '1') { + err = snd_ctl_led_reset(led_card->number, led_card->led->group); + if (err < 0) + return err; + } + return count; +} + +static ssize_t ctl_list(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); + struct snd_card *card; + struct snd_ctl_led_ctl *lctl; + char *buf2 = buf; + size_t l; + + card = snd_card_ref(led_card->number); + if (!card) + return -enxio; + down_read(&card->controls_rwsem); + mutex_lock(&snd_ctl_led_mutex); + if (snd_ctl_led_card_valid[led_card->number]) { + list_for_each_entry(lctl, &led_card->led->controls, list) + if (lctl->card == card) { + if (buf2 - buf > page_size - 16) + break; + if (buf2 != buf) + *buf2++ = ' '; + l = scnprintf(buf2, 15, "%u", + lctl->kctl->id.numid + + lctl->index_offset); + buf2[l] = ''; + buf2 += l + 1; + } + } + mutex_unlock(&snd_ctl_led_mutex); + up_read(&card->controls_rwsem); + snd_card_unref(card); + return buf2 - buf; +} + +static device_attr(attach, 0200, null, parse_attach); +static device_attr(detach, 0200, null, parse_detach); +static device_attr(reset, 0200, null, ctl_reset); +static device_attr(list, 0444, ctl_list, null); + +static struct attribute *snd_ctl_led_card_attrs[] = { + &dev_attr_attach.attr, + &dev_attr_detach.attr, + &dev_attr_reset.attr, + &dev_attr_list.attr, + null, +}; + +static const struct attribute_group snd_ctl_led_card_attr_group = { + .attrs = snd_ctl_led_card_attrs, +}; + +static const struct attribute_group *snd_ctl_led_card_attr_groups[] = { + &snd_ctl_led_card_attr_group, + null, +}; + +static void snd_ctl_led_sysfs_add(struct snd_card *card) +{ + unsigned int group; + struct snd_ctl_led_card *led_card; + struct snd_ctl_led *led; + char link_name[32]; + + for (group = 0; group < max_led; group++) { + led = &snd_ctl_leds[group]; + led_card = kzalloc(sizeof(*led_card), gfp_kernel); + if (!led_card) + goto cerr2; + led_card->number = card->number; + led_card->led = led; + device_initialize(&led_card->dev); + if (dev_set_name(&led_card->dev, "card%d", card->number) < 0) + goto cerr; + led_card->dev.parent = &led->dev; + led_card->dev.groups = snd_ctl_led_card_attr_groups; + if (device_add(&led_card->dev)) + goto cerr; + led->cards[card->number] = led_card; + snprintf(link_name, sizeof(link_name), "led-%s", led->name); + warn(sysfs_create_link(&card->ctl_dev.kobj, &led_card->dev.kobj, link_name), + "can't create symlink to controlc%i device ", card->number); + warn(sysfs_create_link(&led_card->dev.kobj, &card->card_dev.kobj, "card"), + "can't create symlink to card%i ", card->number); + + continue; +cerr: + put_device(&led_card->dev); +cerr2: + printk(kern_err "snd_ctl_led: unable to add card%d", card->number); + kfree(led_card); + } +} + +static void snd_ctl_led_sysfs_remove(struct snd_card *card) +{ + unsigned int group; + struct snd_ctl_led_card *led_card; + struct snd_ctl_led *led; + char link_name[32]; + + for (group = 0; group < max_led; group++) { + led = &snd_ctl_leds[group]; + led_card = led->cards[card->number]; + if (!led_card) + continue; + snprintf(link_name, sizeof(link_name), "led-%s", led->name); + sysfs_remove_link(&card->ctl_dev.kobj, link_name); + sysfs_remove_link(&led_card->dev.kobj, "card"); + device_del(&led_card->dev); + kfree(led_card); + led->cards[card->number] = null; + } +} + - unsigned int group; + struct snd_card *card; + unsigned int group, card_number; + snd_ctl_disconnect_layer(&snd_ctl_led_lops); + for (card_number = 0; card_number < sndrv_cards; card_number++) { + if (!snd_ctl_led_card_valid[card_number]) + continue; + card = snd_card_ref(card_number); + if (card) { + snd_ctl_led_sysfs_remove(card); + snd_card_unref(card); + } + } - snd_ctl_disconnect_layer(&snd_ctl_led_lops);
|
Audio
|
a135dfb5de1501327895729b4f513370d2555b4d
|
jaroslav kysela
|
sound
|
core
| |
dt-bindings: soundwire: qcom: clarify data port bus parameters
|
some of the parameters for data ports are not applicable or not implemented in ip. so mark them as invalid/not applicable in dt so that controller is aware of this.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
various improvements
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['soundwire', 'qcom']
|
['txt']
| 1
| 20
| 0
|
--- diff --git a/documentation/devicetree/bindings/soundwire/qcom,sdw.txt b/documentation/devicetree/bindings/soundwire/qcom,sdw.txt --- a/documentation/devicetree/bindings/soundwire/qcom,sdw.txt +++ b/documentation/devicetree/bindings/soundwire/qcom,sdw.txt + value of 0xff indicates that this option is not implemented + or applicable for the respective data port. - qcom,ports-offset2: + value of 0xff indicates that this option is not implemented + or applicable for the respective data port. - qcom,ports-sinterval-low: + value of 0xff indicates that this option is not implemented + or applicable for the respective data port. - qcom,ports-word-length: + value of 0xff indicates that this option is not implemented + or applicable for the respective data port. - qcom,ports-block-pack-mode: + value of 0xff indicates that this option is not implemented + or applicable for the respective data port. - qcom,ports-block-group-count: + value of 0xff indicates that this option is not implemented + or applicable for the respective data port. - qcom,ports-lane-control: + value of 0xff indicates that this option is not implemented + or applicable for the respective data port. - qcom,ports-hstart: + value of 0xff indicates that this option is not implemented + or applicable for the respective data port. - qcom,ports-hstop: + value of 0xff indicates that this option is not implemented + or applicable for the respective data port. - qcom,dports-type: + value of 0xff indicates that this option is not implemented + or applicable for the respective data port.
|
Audio
|
377785cc7c5d1dafadb1ae43c6d79ff934620f67
|
srinivas kandagatla
|
documentation
|
devicetree
|
bindings, soundwire
|
soundwire: qcom: add support to missing transport params
|
some of the transport parameters derived from device tree are not fully parsed by the driver.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
various improvements
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['soundwire', 'qcom']
|
['c']
| 1
| 94
| 12
|
--- diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c +#define swrm_dp_port_ctrl_2_bank(n, m) (0x1128 + 0x100 * (n - 1) + 0x40 * m) +#define swrm_dp_block_ctrl_1(n) (0x112c + 0x100 * (n - 1)) +#define swrm_dp_block_ctrl2_bank(n, m) (0x1130 + 0x100 * (n - 1) + 0x40 * m) +#define swrm_dp_port_hctrl_bank(n, m) (0x1134 + 0x100 * (n - 1) + 0x40 * m) +#define swrm_din_dpn_pcm_port_ctrl(n) (0x1054 + 0x100 * (n - 1)) + +#define swr_invalid_param 0xff +#define swr_hstop_max_val 0xf +#define swr_hstart_min_val 0x0 + u8 hstart; + u8 hstop; + u8 word_length; + u8 blk_group_count; + u8 lane_control; - /* tbd */ - return 0; + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + + return ctrl->reg_write(ctrl, swrm_dp_block_ctrl_1(p_params->num), + p_params->bps - 1); + + struct qcom_swrm_port_config *pcfg; - value = params->offset1 << swrm_dp_port_ctrl_offset1_shft; - value |= params->offset2 << swrm_dp_port_ctrl_offset2_shft; - value |= params->sample_interval - 1; + pcfg = &ctrl->pconfig[params->port_num - 1]; + + value = pcfg->off1 << swrm_dp_port_ctrl_offset1_shft; + value |= pcfg->off2 << swrm_dp_port_ctrl_offset2_shft; + value |= pcfg->si; - if (!ret && params->blk_pkg_mode) { - reg = swrm_dp_block_ctrl3_bank(params->port_num, bank); + if (pcfg->lane_control != swr_invalid_param) { + reg = swrm_dp_port_ctrl_2_bank(params->port_num, bank); + value = pcfg->lane_control; + ret = ctrl->reg_write(ctrl, reg, value); + } - ret = ctrl->reg_write(ctrl, reg, 1); + if (pcfg->blk_group_count != swr_invalid_param) { + reg = swrm_dp_block_ctrl2_bank(params->port_num, bank); + value = pcfg->blk_group_count; + ret = ctrl->reg_write(ctrl, reg, value); + } + + if (pcfg->hstart != swr_invalid_param + && pcfg->hstop != swr_invalid_param) { + reg = swrm_dp_port_hctrl_bank(params->port_num, bank); + value = (pcfg->hstop << 4) | pcfg->hstart; + ret = ctrl->reg_write(ctrl, reg, value); + } else { + reg = swrm_dp_port_hctrl_bank(params->port_num, bank); + value = (swr_hstop_max_val << 4) | swr_hstart_min_val; + ret = ctrl->reg_write(ctrl, reg, value); + } + + if (pcfg->bp_mode != swr_invalid_param) { + reg = swrm_dp_block_ctrl3_bank(params->port_num, bank); + ret = ctrl->reg_write(ctrl, reg, pcfg->bp_mode); - p_rt->transport_params.sample_interval = pcfg->si + 1; - p_rt->transport_params.offset1 = pcfg->off1; - p_rt->transport_params.offset2 = pcfg->off2; - p_rt->transport_params.blk_pkg_mode = pcfg->bp_mode; + if (pcfg->word_length != swr_invalid_param) { + sdw_fill_port_params(&p_rt->port_params, + p_rt->num, pcfg->word_length + 1, + sdw_port_flow_mode_isoch, + sdw_port_data_mode_normal); + } + + p_rt->transport_params.blk_grp_ctrl = pcfg->blk_group_count; + + p_rt->transport_params.hstart = pcfg->hstart; + p_rt->transport_params.hstop = pcfg->hstop; + p_rt->transport_params.lane_ctrl = pcfg->lane_control; + if (pcfg->word_length != swr_invalid_param) { + sdw_fill_port_params(&p_rt->port_params, + p_rt->num, + pcfg->word_length + 1, + sdw_port_flow_mode_isoch, + sdw_port_data_mode_normal); + } + u8 hstart[qcom_sdw_max_ports]; + u8 hstop[qcom_sdw_max_ports]; + u8 word_length[qcom_sdw_max_ports]; + u8 blk_group_count[qcom_sdw_max_ports]; + u8 lane_control[qcom_sdw_max_ports]; + memset(hstart, swr_invalid_param, qcom_sdw_max_ports); + of_property_read_u8_array(np, "qcom,ports-hstart", hstart, nports); + + memset(hstop, swr_invalid_param, qcom_sdw_max_ports); + of_property_read_u8_array(np, "qcom,ports-hstop", hstop, nports); + + memset(word_length, swr_invalid_param, qcom_sdw_max_ports); + of_property_read_u8_array(np, "qcom,ports-word-length", word_length, nports); + + memset(blk_group_count, swr_invalid_param, qcom_sdw_max_ports); + of_property_read_u8_array(np, "qcom,ports-block-group-count", blk_group_count, nports); + + memset(lane_control, swr_invalid_param, qcom_sdw_max_ports); + of_property_read_u8_array(np, "qcom,ports-lane-control", lane_control, nports); + + ctrl->pconfig[i].hstart = hstart[i]; + ctrl->pconfig[i].hstop = hstop[i]; + ctrl->pconfig[i].word_length = word_length[i]; + ctrl->pconfig[i].blk_group_count = blk_group_count[i]; + ctrl->pconfig[i].lane_control = lane_control[i];
|
Audio
|
128eaf937adb87afc8a14124d3eba1f7a179af0b
|
srinivas kandagatla
|
drivers
|
soundwire
| |
soundwire: qcom: set continue execution flag for ignored commands
|
version 1.5.1 and higher ips of this controller required to set continue execution on ignored command flag. this patch sets this flag.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
various improvements
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['soundwire', 'qcom']
|
['c']
| 1
| 10
| 1
|
--- diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c +#define swrm_continue_exec_on_cmd_ignore bit(31) - ctrl->reg_write(ctrl, swrm_cmd_fifo_cfg_addr, swrm_rd_wr_cmd_retries); + if (ctrl->version > 0x01050001) { + /* only for versions >= 1.5.1 */ + ctrl->reg_write(ctrl, swrm_cmd_fifo_cfg_addr, + swrm_rd_wr_cmd_retries | + swrm_continue_exec_on_cmd_ignore); + } else { + ctrl->reg_write(ctrl, swrm_cmd_fifo_cfg_addr, + swrm_rd_wr_cmd_retries); + }
|
Audio
|
542d3491cdd7975161efe964691f2a1b3bba950f
|
srinivas kandagatla pierre louis bossart pierre louis bossart linux intel com
|
drivers
|
soundwire
| |
soundwire: qcom: start the clock during initialization
|
start the clock during initialization, doing this explicitly will add more clarity when we are adding clock stop feature.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
various improvements
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['soundwire', 'qcom']
|
['c']
| 1
| 3
| 0
|
--- diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c +#define swrm_mcp_bus_ctrl 0x1044 +#define swrm_mcp_bus_clk_start bit(1) + ctrl->reg_write(ctrl, swrm_mcp_bus_ctrl, swrm_mcp_bus_clk_start);
|
Audio
|
a866a049024c789f6d6c35aefab3ae9837a2fa73
|
srinivas kandagatla pierre louis bossart pierre louis bossart linux intel com
|
drivers
|
soundwire
| |
soundwire: qcom: update register read/write routine
|
in the existing code every soundwire register read and register write are kinda blocked. each of these are using a special command id that generates interrupt after it successfully finishes. this is really overhead, limiting and not really necessary unless we are doing something special.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
various improvements
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['soundwire', 'qcom']
|
['c']
| 1
| 100
| 79
|
--- diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c +#define swrm_cmd_fifo_flush 0x1 +#define swrm_rd_fifo_cmd_id_mask genmask(11, 8) -#define qcom_swrm_max_rd_len 0xf +#define qcom_swrm_max_rd_len 0x1 +#define swr_broadcast_cmd_id 0x0f +#define swr_max_cmd_id 14 +#define max_fifo_rd_retry 3 - struct completion *comp; + struct completion broadcast; - /* read/write lock */ - spinlock_t comp_lock; + u8 rcmd_id; + u8 wcmd_id; -static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *ctrl, u8 cmd_data, - u8 dev_addr, u16 reg_addr) +static u32 swrm_get_packed_reg_val(u8 *cmd_id, u8 cmd_data, + u8 dev_addr, u16 reg_addr) - declare_completion_onstack(comp); - unsigned long flags; - int ret; - - spin_lock_irqsave(&ctrl->comp_lock, flags); - ctrl->comp = ∁ - spin_unlock_irqrestore(&ctrl->comp_lock, flags); - val = swrm_reg_val_pack(cmd_data, dev_addr, - swrm_special_cmd_id, reg_addr); - ret = ctrl->reg_write(ctrl, swrm_cmd_fifo_wr_cmd, val); - if (ret) - goto err; - - ret = wait_for_completion_timeout(ctrl->comp, - msecs_to_jiffies(timeout_ms)); + u8 id = *cmd_id; - if (!ret) - ret = sdw_cmd_ignored; - else - ret = sdw_cmd_ok; -err: - spin_lock_irqsave(&ctrl->comp_lock, flags); - ctrl->comp = null; - spin_unlock_irqrestore(&ctrl->comp_lock, flags); + if (id != swr_broadcast_cmd_id) { + if (id < swr_max_cmd_id) + id += 1; + else + id = 0; + *cmd_id = id; + } + val = swrm_reg_val_pack(cmd_data, dev_addr, id, reg_addr); - return ret; + return val; -static int qcom_swrm_cmd_fifo_rd_cmd(struct qcom_swrm_ctrl *ctrl, - u8 dev_addr, u16 reg_addr, - u32 len, u8 *rval) + +static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *swrm, u8 cmd_data, + u8 dev_addr, u16 reg_addr) - int i, ret; - u32 val; - declare_completion_onstack(comp); - unsigned long flags; - spin_lock_irqsave(&ctrl->comp_lock, flags); - ctrl->comp = ∁ - spin_unlock_irqrestore(&ctrl->comp_lock, flags); + u32 val; + int ret = 0; + u8 cmd_id = 0x0; - val = swrm_reg_val_pack(len, dev_addr, swrm_special_cmd_id, reg_addr); - ret = ctrl->reg_write(ctrl, swrm_cmd_fifo_rd_cmd, val); - if (ret) - goto err; + if (dev_addr == sdw_broadcast_dev_num) { + cmd_id = swr_broadcast_cmd_id; + val = swrm_get_packed_reg_val(&cmd_id, cmd_data, + dev_addr, reg_addr); + } else { + val = swrm_get_packed_reg_val(&swrm->wcmd_id, cmd_data, + dev_addr, reg_addr); + } - ret = wait_for_completion_timeout(ctrl->comp, - msecs_to_jiffies(timeout_ms)); + /* its assumed that write is okay as we do not get any status back */ + swrm->reg_write(swrm, swrm_cmd_fifo_wr_cmd, val); + + /* version 1.3 or less */ + if (swrm->version <= 0x01030000) + usleep_range(150, 155); + + if (cmd_id == swr_broadcast_cmd_id) { + /* + * sleep for 10ms for msm soundwire variant to allow broadcast + * command to complete. + */ + ret = wait_for_completion_timeout(&swrm->broadcast, + msecs_to_jiffies(timeout_ms)); + if (!ret) + ret = sdw_cmd_ignored; + else + ret = sdw_cmd_ok; - if (!ret) { - ret = sdw_cmd_ignored; - goto err; + return ret; +} - for (i = 0; i < len; i++) { - ctrl->reg_read(ctrl, swrm_cmd_fifo_rd_fifo_addr, &val); - rval[i] = val & 0xff; - } +static int qcom_swrm_cmd_fifo_rd_cmd(struct qcom_swrm_ctrl *swrm, + u8 dev_addr, u16 reg_addr, + u32 len, u8 *rval) +{ + u32 cmd_data, cmd_id, val, retry_attempt = 0; + + val = swrm_get_packed_reg_val(&swrm->rcmd_id, len, dev_addr, reg_addr); + + /* wait for fifo rd to complete to avoid overflow */ + usleep_range(100, 105); + swrm->reg_write(swrm, swrm_cmd_fifo_rd_cmd, val); + /* wait for fifo rd cmd complete to avoid overflow */ + usleep_range(250, 255); + + do { + swrm->reg_read(swrm, swrm_cmd_fifo_rd_fifo_addr, &cmd_data); + rval[0] = cmd_data & 0xff; + cmd_id = field_get(swrm_rd_fifo_cmd_id_mask, cmd_data); + + if (cmd_id != swrm->rcmd_id) { + if (retry_attempt < (max_fifo_rd_retry - 1)) { + /* wait 500 us before retry on fifo read failure */ + usleep_range(500, 505); + swrm->reg_write(swrm, swrm_cmd_fifo_cmd, + swrm_cmd_fifo_flush); + swrm->reg_write(swrm, swrm_cmd_fifo_rd_cmd, val); + } + retry_attempt++; + } else { + return sdw_cmd_ok; + } -err: - spin_lock_irqsave(&ctrl->comp_lock, flags); - ctrl->comp = null; - spin_unlock_irqrestore(&ctrl->comp_lock, flags); + } while (retry_attempt < max_fifo_rd_retry); - return ret; + dev_err(swrm->dev, "failed to read fifo: reg: 0x%x, rcmd_id: 0x%x,\ + dev_num: 0x%x, cmd_data: 0x%x ", + reg_addr, swrm->rcmd_id, dev_addr, cmd_data); + + return sdw_cmd_ignored; - unsigned long flags; - sts & swrm_interrupt_status_change_enum_slave_status) - schedule_work(&ctrl->slave_work); + sts & swrm_interrupt_status_change_enum_slave_status) { + qcom_swrm_get_device_status(ctrl); + sdw_handle_slave_status(&ctrl->bus, ctrl->status); + } - if (sts & swrm_interrupt_status_special_cmd_id_finished) { - spin_lock_irqsave(&ctrl->comp_lock, flags); - if (ctrl->comp) - complete(ctrl->comp); - spin_unlock_irqrestore(&ctrl->comp_lock, flags); - } + if (sts & swrm_interrupt_status_special_cmd_id_finished) + complete(&ctrl->broadcast); + -static void qcom_swrm_slave_wq(struct work_struct *work) -{ - struct qcom_swrm_ctrl *ctrl = - container_of(work, struct qcom_swrm_ctrl, slave_work); - - qcom_swrm_get_device_status(ctrl); - sdw_handle_slave_status(&ctrl->bus, ctrl->status); -} - - - spin_lock_init(&ctrl->comp_lock); - init_work(&ctrl->slave_work, qcom_swrm_slave_wq); + init_completion(&ctrl->broadcast);
|
Audio
|
ddea6cf7b619ec4b9a630d0073c4fc64d0ac2b9c
|
srinivas kandagatla
|
drivers
|
soundwire
| |
soundwire: qcom: add support to new interrupts
|
add support to new interrupts which includes reporting some of the error interrupts and adding support to slave pending interrupt!
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
various improvements
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['soundwire', 'qcom']
|
['c']
| 1
| 135
| 26
|
--- diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c +#define swrm_interrupt_status_slave_pend_irq bit(0) +#define swrm_interrupt_status_master_clash_det bit(3) +#define swrm_interrupt_status_rd_fifo_overflow bit(4) +#define swrm_interrupt_status_rd_fifo_underflow bit(5) +#define swrm_interrupt_status_wr_cmd_fifo_overflow bit(6) +#define swrm_interrupt_status_dout_port_collision bit(8) +#define swrm_interrupt_status_read_en_rd_valid_mismatch bit(9) +#define swrm_interrupt_status_bus_reset_finished_v2 bit(13) +#define swrm_interrupt_status_clk_stop_finished_v2 bit(14) +#define swrm_interrupt_status_ext_clk_stop_wakeup bit(16) +#define swrm_interrupt_max 17 +#define swrm_mcp_slv_status_sz 2 + u32 intr_mask; +static int qcom_swrm_get_alert_slave_dev_num(struct qcom_swrm_ctrl *ctrl) +{ + u32 val, status; + int dev_num; + + ctrl->reg_read(ctrl, swrm_mcp_slv_status, &val); + + for (dev_num = 0; dev_num < sdw_max_devices; dev_num++) { + status = (val >> (dev_num * swrm_mcp_slv_status_sz)); + + if ((status & swrm_mcp_slv_status_mask) == sdw_slave_alert) { + ctrl->status[dev_num] = status; + return dev_num; + } + } + + return -einval; +} + - struct qcom_swrm_ctrl *ctrl = dev_id; - u32 sts, value; + struct qcom_swrm_ctrl *swrm = dev_id; + u32 value, intr_sts, intr_sts_masked; + u32 i; + u8 devnum = 0; + int ret = irq_handled; - ctrl->reg_read(ctrl, swrm_interrupt_status, &sts); + swrm->reg_read(swrm, swrm_interrupt_status, &intr_sts); + intr_sts_masked = intr_sts & swrm->intr_mask; - if (sts & swrm_interrupt_status_cmd_error) { - ctrl->reg_read(ctrl, swrm_cmd_fifo_status, &value); - dev_err_ratelimited(ctrl->dev, - "cmd error, fifo status 0x%x ", - value); - ctrl->reg_write(ctrl, swrm_cmd_fifo_cmd, 0x1); - } - - if ((sts & swrm_interrupt_status_new_slave_attached) || - sts & swrm_interrupt_status_change_enum_slave_status) { - qcom_swrm_get_device_status(ctrl); - sdw_handle_slave_status(&ctrl->bus, ctrl->status); - } - - /** - * clear the interrupt before complete() is called, as complete can - * schedule new read/writes which require interrupts, clearing the - * interrupt would avoid missing interrupts in such cases. - */ - ctrl->reg_write(ctrl, swrm_interrupt_clear, sts); + do { + for (i = 0; i < swrm_interrupt_max; i++) { + value = intr_sts_masked & bit(i); + if (!value) + continue; + + switch (value) { + case swrm_interrupt_status_slave_pend_irq: + devnum = qcom_swrm_get_alert_slave_dev_num(swrm); + if (devnum < 0) { + dev_err_ratelimited(swrm->dev, + "no slave alert found.spurious interrupt "); + } else { + sdw_handle_slave_status(&swrm->bus, swrm->status); + } - if (sts & swrm_interrupt_status_special_cmd_id_finished) - complete(&ctrl->broadcast); + break; + case swrm_interrupt_status_new_slave_attached: + case swrm_interrupt_status_change_enum_slave_status: + dev_err_ratelimited(swrm->dev, "%s: swr new slave attached ", + __func__); + qcom_swrm_get_device_status(swrm); + sdw_handle_slave_status(&swrm->bus, swrm->status); + break; + case swrm_interrupt_status_master_clash_det: + dev_err_ratelimited(swrm->dev, + "%s: swr bus clsh detected ", + __func__); + swrm->intr_mask &= ~swrm_interrupt_status_master_clash_det; + swrm->reg_write(swrm, swrm_interrupt_cpu_en, swrm->intr_mask); + break; + case swrm_interrupt_status_rd_fifo_overflow: + swrm->reg_read(swrm, swrm_cmd_fifo_status, &value); + dev_err_ratelimited(swrm->dev, + "%s: swr read fifo overflow fifo status 0x%x ", + __func__, value); + break; + case swrm_interrupt_status_rd_fifo_underflow: + swrm->reg_read(swrm, swrm_cmd_fifo_status, &value); + dev_err_ratelimited(swrm->dev, + "%s: swr read fifo underflow fifo status 0x%x ", + __func__, value); + break; + case swrm_interrupt_status_wr_cmd_fifo_overflow: + swrm->reg_read(swrm, swrm_cmd_fifo_status, &value); + dev_err(swrm->dev, + "%s: swr write fifo overflow fifo status %x ", + __func__, value); + swrm->reg_write(swrm, swrm_cmd_fifo_cmd, 0x1); + break; + case swrm_interrupt_status_cmd_error: + swrm->reg_read(swrm, swrm_cmd_fifo_status, &value); + dev_err_ratelimited(swrm->dev, + "%s: swr cmd error, fifo status 0x%x, flushing fifo ", + __func__, value); + swrm->reg_write(swrm, swrm_cmd_fifo_cmd, 0x1); + break; + case swrm_interrupt_status_dout_port_collision: + dev_err_ratelimited(swrm->dev, + "%s: swr port collision detected ", + __func__); + swrm->intr_mask &= ~swrm_interrupt_status_dout_port_collision; + swrm->reg_write(swrm, + swrm_interrupt_cpu_en, swrm->intr_mask); + break; + case swrm_interrupt_status_read_en_rd_valid_mismatch: + dev_err_ratelimited(swrm->dev, + "%s: swr read enable valid mismatch ", + __func__); + swrm->intr_mask &= + ~swrm_interrupt_status_read_en_rd_valid_mismatch; + swrm->reg_write(swrm, + swrm_interrupt_cpu_en, swrm->intr_mask); + break; + case swrm_interrupt_status_special_cmd_id_finished: + complete(&swrm->broadcast); + break; + case swrm_interrupt_status_bus_reset_finished_v2: + break; + case swrm_interrupt_status_clk_stop_finished_v2: + break; + case swrm_interrupt_status_ext_clk_stop_wakeup: + break; + default: + dev_err_ratelimited(swrm->dev, + "%s: swr unknown interrupt value: %d ", + __func__, value); + ret = irq_none; + break; + } + } + swrm->reg_write(swrm, swrm_interrupt_clear, intr_sts); + swrm->reg_read(swrm, swrm_interrupt_status, &intr_sts); + intr_sts_masked = intr_sts & swrm->intr_mask; + } while (intr_sts_masked); - return irq_handled; + return ret; + ctrl->intr_mask = swrm_interrupt_status_rmsk;
|
Audio
|
c7d49c76d1d5f5a41f637c18ce3b756351c7fdf9
|
srinivas kandagatla
|
drivers
|
soundwire
| |
soundwire: export sdw_compare_devid, sdw_extract_slave_id and sdw_slave_add
|
exporting these three functions makes sense as it can be used by other controllers like qualcomm during auto-enumeration!
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
various improvements
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['soundwire', 'qcom']
|
['h', 'c']
| 3
| 6
| 1
|
--- diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c -static int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id) +int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id) +export_symbol(sdw_compare_devid); +export_symbol(sdw_extract_slave_id); diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c --- a/drivers/soundwire/slave.c +++ b/drivers/soundwire/slave.c +export_symbol(sdw_slave_add); diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h +int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id); +void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id);
|
Audio
|
01ad444e3be719f8ad13f136a9b0d301806183c8
|
srinivas kandagatla
|
drivers
|
soundwire
|
soundwire
|
soundwire: qcom: add auto enumeration support
|
qualcomm soundwire controller supports auto enumeration of the devices within the ip. this patch enables support for this feature.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
various improvements
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['soundwire', 'qcom']
|
['c']
| 1
| 81
| 5
|
--- diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c +#define swrm_enumerator_slave_dev_id_1(m) (0x530 + 0x8 * (m)) +#define swrm_enumerator_slave_dev_id_2(m) (0x534 + 0x8 * (m)) + u32 slave_status; + ctrl->slave_status = val; +static void qcom_swrm_set_slave_dev_num(struct sdw_bus *bus, + struct sdw_slave *slave, int devnum) +{ + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + u32 status; + + ctrl->reg_read(ctrl, swrm_mcp_slv_status, &status); + status = (status >> (devnum * swrm_mcp_slv_status_sz)); + status &= swrm_mcp_slv_status_mask; + + if (status == sdw_slave_attached) { + if (slave) + slave->dev_num = devnum; + mutex_lock(&bus->bus_lock); + set_bit(devnum, bus->assigned); + mutex_unlock(&bus->bus_lock); + } +} + +static int qcom_swrm_enumerate(struct sdw_bus *bus) +{ + struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus); + struct sdw_slave *slave, *_s; + struct sdw_slave_id id; + u32 val1, val2; + bool found; + u64 addr; + int i; + char *buf1 = (char *)&val1, *buf2 = (char *)&val2; + + for (i = 1; i <= sdw_max_devices; i++) { + /*scp_devid5 - devid 4*/ + ctrl->reg_read(ctrl, swrm_enumerator_slave_dev_id_1(i), &val1); + + /*scp_devid3 - devid 2 devid 1 devid 0*/ + ctrl->reg_read(ctrl, swrm_enumerator_slave_dev_id_2(i), &val2); + + if (!val1 && !val2) + break; + + addr = buf2[1] | (buf2[0] << 8) | (buf1[3] << 16) | + ((u64)buf1[2] << 24) | ((u64)buf1[1] << 32) | + ((u64)buf1[0] << 40); + + sdw_extract_slave_id(bus, addr, &id); + found = false; + /* now compare with entries */ + list_for_each_entry_safe(slave, _s, &bus->slaves, node) { + if (sdw_compare_devid(slave, id) == 0) { + qcom_swrm_set_slave_dev_num(bus, slave, i); + found = true; + break; + } + } + + if (!found) { + qcom_swrm_set_slave_dev_num(bus, null, i); + sdw_slave_add(bus, &id, null); + } + } + + return 0; +} + - u32 value, intr_sts, intr_sts_masked; + u32 value, intr_sts, intr_sts_masked, slave_status; - qcom_swrm_get_device_status(swrm); - sdw_handle_slave_status(&swrm->bus, swrm->status); + swrm->reg_read(swrm, swrm_mcp_slv_status, &slave_status); + if (swrm->slave_status == slave_status) { + dev_err(swrm->dev, "slave status not changed %x ", + slave_status); + } else { + qcom_swrm_get_device_status(swrm); + qcom_swrm_enumerate(&swrm->bus); + sdw_handle_slave_status(&swrm->bus, swrm->status); + } - /* disable auto enumeration */ - ctrl->reg_write(ctrl, swrm_enumerator_cfg_addr, 0); + /* enable auto enumeration */ + ctrl->reg_write(ctrl, swrm_enumerator_cfg_addr, 1); + ctrl->slave_status = 0;
|
Audio
|
a6e6581942caa0fab059634459c4c349fd7e4cc2
|
srinivas kandagatla pierre louis bossart pierre louis bossart linux intel com
|
drivers
|
soundwire
| |
soundwire: qcom: wait for enumeration to be complete in probe
|
signed-off-by: srinivas kandagatla <srinivas.kandagatla@linaro.org> reviewed-by: pierre-louis bossart <pierre-louis.bossart@linux.intel.com> link: https://lore.kernel.org/r/20210330144719.13284-10-srinivas.kandagatla@linaro.org signed-off-by: vinod koul <vkoul@kernel.org>
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
various improvements
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['soundwire', 'qcom']
|
['c']
| 1
| 5
| 0
|
--- diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c + struct completion enumeration; + complete(&ctrl->enumeration); + init_completion(&ctrl->enumeration); + wait_for_completion_timeout(&ctrl->enumeration, + msecs_to_jiffies(timeout_ms));
|
Audio
|
06dd96738d618391ae58e1b28f1ba49fef214c95
|
srinivas kandagatla
|
drivers
|
soundwire
| |
alsa: bebob: enable to deliver midi messages for multiple ports
|
current implementation of bebob driver doesn't correctly handle the case that the device has multiple midi ports. the cause is the number of midi conformant data channels is passed to am824 data block processing layer.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
enable to deliver midi messages for multiple ports
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['bebob']
|
['c']
| 1
| 7
| 5
|
--- diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c - struct snd_bebob_stream_formation *formation; + unsigned int pcm_channels; + unsigned int midi_ports; - formation = bebob->tx_stream_formations + index; + pcm_channels = bebob->tx_stream_formations[index].pcm; + midi_ports = bebob->midi_input_ports; - formation = bebob->rx_stream_formations + index; + pcm_channels = bebob->rx_stream_formations[index].pcm; + midi_ports = bebob->midi_output_ports; - err = amdtp_am824_set_parameters(stream, rate, formation->pcm, - formation->midi, false); + err = amdtp_am824_set_parameters(stream, rate, pcm_channels, midi_ports, false);
|
Audio
|
d2b6f15bc18ac8fbce25398290774c21f5b2cd44
|
takashi sakamoto
|
sound
|
firewire
|
bebob
|
alsa: hda/cirrus: increase auto_cfg_max_ins from 8 to 18
|
in preparation to support cirrus logic cs8409 hda bridge on new dell platforms it is nessasary to increase auto_cfg_max_ins and auto_cfg_num_inputs values. currently auto_cfg_max_ins is limited to 8, but cirrus logic hda bridge cs8409 has 18 input pins, 16 asp receivers and 2 dmic inputs. we have to increase this value to 18, so generic code can handle this correctly.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for cs8409 hda bridge and cs42l42 companion codec
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['hda ', 'cirrus']
|
['h']
| 2
| 2
| 2
|
--- diff --git a/sound/pci/hda/hda_auto_parser.h b/sound/pci/hda/hda_auto_parser.h --- a/sound/pci/hda/hda_auto_parser.h +++ b/sound/pci/hda/hda_auto_parser.h -#define auto_cfg_max_ins 8 +#define auto_cfg_max_ins 18 diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h -#define hda_max_num_inputs 16 +#define hda_max_num_inputs 36
|
Audio
|
b95a913cb368edcb606d844a6dc6240093d87020
|
vitaly rodionov
|
sound
|
pci
|
hda
|
alsa: hda/cirrus: add support for cs8409 hda bridge and cs42l42 companion codec.
|
dell's laptops inspiron 3500, inspiron 3501, inspiron 3505 are using cirrus logic cs8409 hda bridge with cs42l42 companion codec.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for cs8409 hda bridge and cs42l42 companion codec
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['hda ', 'cirrus']
|
['c']
| 1
| 576
| 0
|
------- -------- --- diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c +#include <linux/pci.h> +/* cirrus logic cs8409 hda bridge with + * companion codec cs42l42 + */ +#define cs8409_vendor_nid 0x47 + +#define cs8409_cs42l42_hp_pin_nid 0x24 +#define cs8409_cs42l42_spk_pin_nid 0x2c +#define cs8409_cs42l42_amic_pin_nid 0x34 +#define cs8409_cs42l42_dmic_pin_nid 0x44 + +#define gpio3_int (1 << 3) +#define gpio4_int (1 << 4) +#define gpio5_int (1 << 5) + +#define cs42l42_i2c_addr (0x48 << 1) + +#define cir_i2c_addr 0x0059 +#define cir_i2c_data 0x005a +#define cir_i2c_ctrl 0x005b +#define cir_i2c_status 0x005c +#define cir_i2c_qwrite 0x005d +#define cir_i2c_qread 0x005e + +struct cs8409_i2c_param { + unsigned int addr; + unsigned int reg; +}; + +struct cs8409_cir_param { + unsigned int nid; + unsigned int cir; + unsigned int coeff; +}; + +enum { + cs8409_bullseye, + cs8409_warlock, + cs8409_cyborg, + cs8409_verbs, +}; + +/* dell inspiron models with cs8409/cs42l42 */ +static const struct hda_model_fixup cs8409_models[] = { + { .id = cs8409_bullseye, .name = "bullseye" }, + { .id = cs8409_warlock, .name = "warlock" }, + { .id = cs8409_cyborg, .name = "cyborg" }, + {} +}; + +/* dell inspiron platforms + * with cs8409 bridge and cs42l42 codec + */ +static const struct snd_pci_quirk cs8409_fixup_tbl[] = { + snd_pci_quirk(0x1028, 0x0a11, "bullseye", cs8409_bullseye), + snd_pci_quirk(0x1028, 0x0a12, "bullseye", cs8409_bullseye), + snd_pci_quirk(0x1028, 0x0a23, "bullseye", cs8409_bullseye), + snd_pci_quirk(0x1028, 0x0a24, "bullseye", cs8409_bullseye), + snd_pci_quirk(0x1028, 0x0a25, "bullseye", cs8409_bullseye), + snd_pci_quirk(0x1028, 0x0a29, "bullseye", cs8409_bullseye), + snd_pci_quirk(0x1028, 0x0a2a, "bullseye", cs8409_bullseye), + snd_pci_quirk(0x1028, 0x0a2b, "bullseye", cs8409_bullseye), + snd_pci_quirk(0x1028, 0x0ab0, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0ab2, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0ab1, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0ab3, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0ab4, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0ab5, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0ad9, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0ada, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0adb, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0adc, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0af4, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0af5, "warlock", cs8409_warlock), + snd_pci_quirk(0x1028, 0x0a77, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0a78, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0a79, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0a7a, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0a7d, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0a7e, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0a7f, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0a80, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0adf, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0ae0, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0ae1, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0ae2, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0ae9, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0aea, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0aeb, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0aec, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0aed, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0aee, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0aef, "cyborg", cs8409_cyborg), + snd_pci_quirk(0x1028, 0x0af0, "cyborg", cs8409_cyborg), + {} /* terminator */ +}; + +static const struct hda_verb cs8409_cs42l42_init_verbs[] = { + { 0x01, ac_verb_set_gpio_wake_mask, 0x0018 }, /* wake from gpio 3,4 */ + { 0x47, ac_verb_set_proc_state, 0x0001 }, /* enable vpw processing */ + { 0x47, ac_verb_set_coef_index, 0x0002 }, /* configure gpio 6,7 */ + { 0x47, ac_verb_set_proc_coef, 0x0080 }, /* i2c mode */ + { 0x47, ac_verb_set_coef_index, 0x005b }, /* set i2c bus speed */ + { 0x47, ac_verb_set_proc_coef, 0x0200 }, /* 100khz i2c_sto = 2 */ + {} /* terminator */ +}; + +static const struct hda_pintbl cs8409_cs42l42_pincfgs[] = { + { 0x24, 0x042120f0 }, /* asp-1-tx */ + { 0x34, 0x04a12050 }, /* asp-1-rx */ + { 0x2c, 0x901000f0 }, /* asp-2-tx */ + { 0x44, 0x90a00090 }, /* dmic-1 */ + {} /* terminator */ +}; + +static const struct hda_verb cs8409_cs42l42_add_verbs[] = { + { 0x24, 0x71c, 0xf0 }, /* widget node asp-1-tx */ + { 0x24, 0x71d, 0x20 }, + { 0x24, 0x71e, 0x21 }, + { 0x24, 0x71f, 0x04 }, + { 0x34, 0x71c, 0x50 }, /* widget node asp-1-rx0 */ + { 0x34, 0x71d, 0x20 }, + { 0x34, 0x71e, 0xa1 }, + { 0x34, 0x71f, 0x04 }, + { 0x2c, 0x71c, 0xf0 }, /* widget node asp-2-tx */ + { 0x2c, 0x71d, 0x00 }, + { 0x2c, 0x71e, 0x10 }, + { 0x2c, 0x71f, 0x90 }, + { 0x44, 0x71c, 0x90 }, /* widget node dmic-1 */ + { 0x44, 0x71d, 0x00 }, + { 0x44, 0x71e, 0xa0 }, + { 0x44, 0x71f, 0x90 }, + {} /* terminator */ +}; + +static const struct hda_fixup cs8409_fixups[] = { + [cs8409_bullseye] = { + .type = hda_fixup_pins, + .v.pins = cs8409_cs42l42_pincfgs, + .chained = true, + .chain_id = cs8409_verbs, + }, + [cs8409_warlock] = { + .type = hda_fixup_pins, + .v.pins = cs8409_cs42l42_pincfgs, + .chained = true, + .chain_id = cs8409_verbs, + }, + [cs8409_cyborg] = { + .type = hda_fixup_pins, + .v.pins = cs8409_cs42l42_pincfgs, + .chained = true, + .chain_id = cs8409_verbs, + }, + [cs8409_verbs] = { + .type = hda_fixup_verbs, + .v.verbs = cs8409_cs42l42_add_verbs, + }, +}; + +/* vendor specific hw configuration for cs42l42 */ +static const struct cs8409_i2c_param cs42l42_init_reg_seq[] = { + { 0x1010, 0xb0 }, + { 0x1d01, 0x00 }, + { 0x1d02, 0x06 }, + { 0x1d03, 0x00 }, + { 0x1107, 0x01 }, + { 0x1009, 0x02 }, + { 0x1007, 0x03 }, + { 0x1201, 0x00 }, + { 0x1208, 0x13 }, + { 0x1205, 0xff }, + { 0x1206, 0x00 }, + { 0x1207, 0x20 }, + { 0x1202, 0x0d }, + { 0x2a02, 0x02 }, + { 0x2a03, 0x00 }, + { 0x2a04, 0x00 }, + { 0x2a05, 0x02 }, + { 0x2a06, 0x00 }, + { 0x2a07, 0x20 }, + { 0x2a08, 0x02 }, + { 0x2a09, 0x00 }, + { 0x2a0a, 0x80 }, + { 0x2a0b, 0x02 }, + { 0x2a0c, 0x00 }, + { 0x2a0d, 0xa0 }, + { 0x2a01, 0x0c }, + { 0x2902, 0x01 }, + { 0x2903, 0x02 }, + { 0x2904, 0x00 }, + { 0x2905, 0x00 }, + { 0x2901, 0x01 }, + { 0x1101, 0x0a }, + { 0x1102, 0x84 }, + { 0x2301, 0x00 }, + { 0x2303, 0x00 }, + { 0x2302, 0x3f }, + { 0x2001, 0x03 }, + { 0x1b75, 0xb6 }, + { 0x1b73, 0xc2 }, + { 0x1129, 0x01 }, + { 0x1121, 0xf3 }, + { 0x1103, 0x20 }, + { 0x1105, 0x00 }, + { 0x1112, 0xc0 }, + { 0x1113, 0x80 }, + { 0x1c03, 0xc0 }, + { 0x1105, 0x00 }, + { 0x1112, 0xc0 }, + {} /* terminator */ +}; + +/* vendor specific hw configuration for cs8409 */ +static const struct cs8409_cir_param cs8409_cs42l42_hw_cfg[] = { + { 0x47, 0x00, 0xb008 }, /* +pll1/2_en, +i2c_en */ + { 0x47, 0x01, 0x0002 }, /* asp1/2_en=0, asp1_stp=1 */ + { 0x47, 0x02, 0x0a80 }, /* asp1/2_bus_idle=10, +gpio_i2c */ + { 0x47, 0x19, 0x0800 }, /* asp1.a: tx.lap=0, tx.lsz=24 bits, tx.lcs=0 */ + { 0x47, 0x1a, 0x0820 }, /* asp1.a: tx.rap=0, tx.rsz=24 bits, tx.rcs=32 */ + { 0x47, 0x29, 0x0800 }, /* asp2.a: tx.lap=0, tx.lsz=24 bits, tx.lcs=0 */ + { 0x47, 0x2a, 0x2800 }, /* asp2.a: tx.rap=1, tx.rsz=24 bits, tx.rcs=0 */ + { 0x47, 0x39, 0x0800 }, /* asp1.a: rx.lap=0, rx.lsz=24 bits, rx.lcs=0 */ + { 0x47, 0x3a, 0x0800 }, /* asp1.a: rx.rap=0, rx.rsz=24 bits, rx.rcs=0 */ + { 0x47, 0x03, 0x8000 }, /* asp1: lchi = 00h */ + { 0x47, 0x04, 0x28ff }, /* asp1: mc/sc_srcsel=pll1, lcpr=ffh */ + { 0x47, 0x05, 0x0062 }, /* asp1: mcen=0, fsd=011, scpol_in/out=0, scdiv=1:4 */ + { 0x47, 0x06, 0x801f }, /* asp2: lchi=1fh */ + { 0x47, 0x07, 0x283f }, /* asp2: mc/sc_srcsel=pll1, lcpr=3fh */ + { 0x47, 0x08, 0x805c }, /* asp2: 5050=1, mcen=0, fsd=010, scpol_in/out=1, scdiv=1:16 */ + { 0x47, 0x09, 0x0023 }, /* dmic1_mo=10b, dmic1/2_sr=1 */ + { 0x47, 0x0a, 0x0000 }, /* asp1/2_beep=0 */ + { 0x47, 0x01, 0x0062 }, /* asp1/2_en=1, asp1_stp=1 */ + { 0x47, 0x00, 0x9008 }, /* -pll2_en */ + { 0x47, 0x68, 0x0000 }, /* tx2.a: pre-scale att.=0 db */ + { 0x47, 0x82, 0xfc03 }, /* asp1/2_xxx_en=1, asp1/2_mclk_en=0, dmic1_scl_en=1 */ + { 0x47, 0xc0, 0x9999 }, /* test mode on */ + { 0x47, 0xc5, 0x0000 }, /* gpio hysteresis = 30 us */ + { 0x47, 0xc0, 0x0000 }, /* test mode off */ + {} /* terminator */ +}; + +/* enable i2c clocks */ +static void cs8409_enable_i2c_clock(struct hda_codec *codec, unsigned int flag) +{ + unsigned int retval = 0; + unsigned int newval = 0; + + retval = cs_vendor_coef_get(codec, 0x0); + newval = (flag) ? (retval | 0x8) : (retval & 0xfffffff7); + cs_vendor_coef_set(codec, 0x0, newval); +} + +/* wait i2c transaction */ +static int cs8409_i2c_wait_complete(struct hda_codec *codec) +{ + int repeat = 5; + unsigned int retval = 0; + + do { + retval = cs_vendor_coef_get(codec, cir_i2c_status); + if ((retval & 0x18) != 0x18) { + usleep_range(2000, 4000); + --repeat; + } else + break; + + } while (repeat); + + return repeat > 0 ? 0 : -1; +} + +/* cs8409 slave i2cread */ +static unsigned int cs8409_i2c_read(struct hda_codec *codec, + unsigned int i2c_address, + unsigned int i2c_reg, + unsigned int paged) +{ + unsigned int i2c_reg_data; + unsigned int retval = 0; + + cs8409_enable_i2c_clock(codec, 1); + cs_vendor_coef_set(codec, cir_i2c_addr, i2c_address); + + if (paged) { + cs_vendor_coef_set(codec, cir_i2c_qwrite, i2c_reg >> 8); + if (cs8409_i2c_wait_complete(codec) == -1) { + codec_err(codec, + "%s() paged transaction failed 0x%02x : 0x%04x = 0x%02x ", + __func__, i2c_address, i2c_reg, retval); + } + } + + i2c_reg_data = (i2c_reg << 8) & 0x0ffff; + cs_vendor_coef_set(codec, cir_i2c_qread, i2c_reg_data); + if (cs8409_i2c_wait_complete(codec) == -1) { + codec_err(codec, "%s() transaction failed 0x%02x : 0x%04x = 0x%02x ", + __func__, i2c_address, i2c_reg, retval); + } + + /* register in bits 15-8 and the data in 7-0 */ + retval = cs_vendor_coef_get(codec, cir_i2c_qread); + retval &= 0x0ff; + + cs8409_enable_i2c_clock(codec, 0); + + return retval; +} + +/* cs8409 slave i2cwrite */ +static unsigned int cs8409_i2c_write(struct hda_codec *codec, + unsigned int i2c_address, unsigned int i2c_reg, + unsigned int i2c_data, + unsigned int paged) +{ + unsigned int retval = 0; + unsigned int i2c_reg_data = 0; + + cs8409_enable_i2c_clock(codec, 1); + cs_vendor_coef_set(codec, cir_i2c_addr, i2c_address); + + if (paged) { + cs_vendor_coef_set(codec, cir_i2c_qwrite, i2c_reg >> 8); + if (cs8409_i2c_wait_complete(codec) == -1) { + codec_err(codec, + "%s() paged transaction failed 0x%02x : 0x%04x = 0x%02x ", + __func__, i2c_address, i2c_reg, retval); + } + } + + i2c_reg_data = ((i2c_reg << 8) & 0x0ff00) | (i2c_data & 0x0ff); + cs_vendor_coef_set(codec, cir_i2c_qwrite, i2c_reg_data); + + if (cs8409_i2c_wait_complete(codec) == -1) { + codec_err(codec, "%s() transaction failed 0x%02x : 0x%04x = 0x%02x ", + __func__, i2c_address, i2c_reg, retval); + } + + cs8409_enable_i2c_clock(codec, 0); + + return retval; +} + +/* assert/release rts# line to cs42l42 */ +static void cs8409_cs42l42_reset(struct hda_codec *codec) +{ + /* assert rts# line */ + snd_hda_codec_write(codec, + codec->core.afg, 0, ac_verb_set_gpio_data, 0); + /* wait ~10ms */ + usleep_range(10000, 15000); + /* release rts# line */ + snd_hda_codec_write(codec, + codec->core.afg, 0, ac_verb_set_gpio_data, gpio5_int); + /* wait ~10ms */ + usleep_range(10000, 15000); + + /* clear interrupts status */ + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x1308, 1); + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x1309, 1); + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x130a, 1); + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x130f, 1); + +} + +static void cs8409_cs42l42_reg_setup(struct hda_codec *codec) +{ + const struct cs8409_i2c_param *seq = cs42l42_init_reg_seq; + + for (; seq->addr; seq++) + cs8409_i2c_write(codec, cs42l42_i2c_addr, seq->addr, seq->reg, 1); + +} + +static int cs8409_cs42l42_build_controls(struct hda_codec *codec) +{ + int err; + + err = snd_hda_gen_build_controls(codec); + if (err < 0) + return err; + + snd_hda_apply_fixup(codec, hda_fixup_act_build); + + return 0; +} + +#ifdef config_pm +/* manage pdref, when transition to d3hot */ +static int cs8409_suspend(struct hda_codec *codec) +{ + /* assert cs42l42 rts# line */ + snd_hda_codec_write(codec, + codec->core.afg, 0, ac_verb_set_gpio_data, 0); + snd_hda_shutup_pins(codec); + return 0; +} +#endif + +/* vendor specific hw configuration + * pll, asp, i2c, spi, gpios, dmic etc... + */ +static int cs8409_cs42l42_hw_init(struct hda_codec *codec) +{ + const struct cs8409_cir_param *seq = cs8409_cs42l42_hw_cfg; + struct cs_spec *spec = codec->spec; + + if (spec->gpio_mask) { + snd_hda_codec_write(codec, 0x01, 0, ac_verb_set_gpio_mask, + spec->gpio_mask); + snd_hda_codec_write(codec, 0x01, 0, ac_verb_set_gpio_direction, + spec->gpio_dir); + snd_hda_codec_write(codec, 0x01, 0, ac_verb_set_gpio_data, + spec->gpio_data); + } + + for (; seq->nid; seq++) + cs_vendor_coef_set(codec, seq->cir, seq->coeff); + + /* reset cs42l42 */ + cs8409_cs42l42_reset(codec); + + /* initialise cs42l42 companion codec */ + cs8409_cs42l42_reg_setup(codec); + + if (codec->fixup_id == cs8409_warlock || + codec->fixup_id == cs8409_cyborg) { + /* full_scale_vol = 0 for warlock / cyborg */ + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x2001, 0x01, 1); + /* dmic1_mo=00b, dmic1/2_sr=1 */ + cs_vendor_coef_set(codec, 0x09, 0x0003); + } + + return 1; +} + +static int cs8409_cs42l42_init(struct hda_codec *codec) +{ + int ret = 0; + + ret = snd_hda_gen_init(codec); + + if (!ret) { + /* on dell platforms with suspend d3 mode support we + * have to re-initialise cs8409 bridge and companion + * cs42l42 codec + */ + snd_hda_sequence_write(codec, cs8409_cs42l42_init_verbs); + snd_hda_sequence_write(codec, cs8409_cs42l42_add_verbs); + + cs8409_cs42l42_hw_init(codec); + + } + + return ret; +} + +static const struct hda_codec_ops cs8409_cs42l42_patch_ops = { + .build_controls = cs8409_cs42l42_build_controls, + .build_pcms = snd_hda_gen_build_pcms, + .init = cs8409_cs42l42_init, + .free = cs_free, + .unsol_event = snd_hda_jack_unsol_event, +#ifdef config_pm + .suspend = cs8409_suspend, +#endif +}; + +static int cs8409_cs42l42_fixup(struct hda_codec *codec) +{ + int err = 0; + struct cs_spec *spec = codec->spec; + unsigned int pincap = 0; + + /* basic initial sequence for specific hw configuration */ + snd_hda_sequence_write(codec, cs8409_cs42l42_init_verbs); + + /* cs8409 is simple hda bridge and intended to be used with a remote + * companion codec. most of input/output pin(s) have only basic + * capabilities. nid(s) 0x24 and 0x34 have only outc and inc + * capabilities and no presence detect capable (pdc) and call to + * snd_hda_gen_build_controls() will mark them as non detectable + * phantom jacks. however, in this configuration companion codec + * cs42l42 is connected to these pins and it has jack detect + * capabilities. we have to override pin capabilities, + * otherwise they will not be created as input devices. + */ + _snd_hdac_read_parm(&codec->core, + cs8409_cs42l42_hp_pin_nid, ac_par_pin_cap, &pincap); + + snd_hdac_override_parm(&codec->core, + cs8409_cs42l42_hp_pin_nid, ac_par_pin_cap, + (pincap | (ac_pincap_imp_sense | ac_pincap_pres_detect))); + + _snd_hdac_read_parm(&codec->core, cs8409_cs42l42_amic_pin_nid, + ac_par_pin_cap, &pincap); + + snd_hdac_override_parm(&codec->core, + cs8409_cs42l42_amic_pin_nid, ac_par_pin_cap, + (pincap | (ac_pincap_imp_sense | ac_pincap_pres_detect))); + + snd_hda_override_wcaps(codec, cs8409_cs42l42_hp_pin_nid, + (get_wcaps(codec, cs8409_cs42l42_hp_pin_nid) | ac_wcap_unsol_cap)); + + snd_hda_override_wcaps(codec, cs8409_cs42l42_amic_pin_nid, + (get_wcaps(codec, cs8409_cs42l42_amic_pin_nid) | ac_wcap_unsol_cap)); + + snd_hda_apply_fixup(codec, hda_fixup_act_pre_probe); + + err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, 0, 0); + if (err < 0) + return err; + + err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); + if (err < 0) + return err; + + snd_hda_apply_fixup(codec, hda_fixup_act_probe); + + return err; +} + +static int patch_cs8409(struct hda_codec *codec) +{ + struct cs_spec *spec; + int err = -einval; + + spec = cs_alloc_spec(codec, cs8409_vendor_nid); + if (!spec) + return -enomem; + + snd_hda_pick_fixup(codec, + cs8409_models, cs8409_fixup_tbl, cs8409_fixups); + + codec_dbg(codec, "picked id=%d, vid=%08x, dev=%08x ", + codec->fixup_id, + codec->bus->pci->subsystem_vendor, + codec->bus->pci->subsystem_device); + + switch (codec->fixup_id) { + /* dell platforms with cs42l42 companion codec */ + case cs8409_bullseye: + case cs8409_warlock: + case cs8409_cyborg: + + snd_hda_add_verbs(codec, cs8409_cs42l42_add_verbs); + + codec->patch_ops = cs8409_cs42l42_patch_ops; + + spec->gen.suppress_auto_mute = 1; + spec->gen.no_primary_hp = 1; + /* gpio 5 out, 3,4 in */ + spec->gpio_dir = gpio5_int; + spec->gpio_data = 0; + spec->gpio_mask = 0x03f; + + err = cs8409_cs42l42_fixup(codec); + + if (err > 0) + err = cs8409_cs42l42_hw_init(codec); + break; + + default: + codec_err(codec, "vid=%08x, dev=%08x not supported ", + codec->bus->pci->subsystem_vendor, + codec->bus->pci->subsystem_device); + break; + } + if (err < 0) + cs_free(codec); + else + snd_hda_codec_set_name(codec, "cs8409/cs42l42"); + + return err; +} + hda_codec_entry(0x10138409, "cs8409", patch_cs8409),
|
Audio
|
6cc7e93f46a5ce9f65ad3c6c6f645f1d831a8fa4
|
vitaly rodionov
|
sound
|
pci
|
hda
|
alsa: hda/cirrus: add jack detect interrupt support from cs42l42 companion codec.
|
in the case of cs8409 we do not have unsol events from nid's 0x24 and 0x34 where hs mic and hp are connected. companion codec cs42l42 will generate interrupt via gpio 4 to notify jack events. we have to overwrite standard snd_hda_jack_unsol_event(), read cs42l42 jack detect status registers and then notify status via generic snd_hda_jack_unsol_event() call.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for cs8409 hda bridge and cs42l42 companion codec
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['hda ', 'cirrus']
|
['c']
| 1
| 307
| 2
|
--- diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c +#include <linux/mutex.h> + + unsigned int cs42l42_hp_jack_in:1; + unsigned int cs42l42_mic_jack_in:1; + + struct mutex cs8409_i2c_mux; + + /* verb exec op override */ + int (*exec_verb)(struct hdac_device *dev, unsigned int cmd, + unsigned int flags, unsigned int *res); +#define cs8409_cs42l42_dmic_adc_pin_nid 0x22 + +#define cs42l42_hsdet_auto_done 0x02 +#define cs42l42_hstype_mask 0x03 + +#define cs42l42_jack_inserted 0x0c +#define cs42l42_jack_removed 0x00 + { 0x1101, 0x02 }, + struct cs_spec *spec = codec->spec; + - /* clear interrupts status */ + mutex_lock(&spec->cs8409_i2c_mux); + + /* clear interrupts, by reading interrupt status registers */ + mutex_unlock(&spec->cs8409_i2c_mux); + +} + +/* configure cs42l42 slave codec for jack autodetect */ +static int cs8409_cs42l42_enable_jack_detect(struct hda_codec *codec) +{ + struct cs_spec *spec = codec->spec; + + mutex_lock(&spec->cs8409_i2c_mux); + + /* set tip_sense_en for analog front-end of tip sense. */ + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1b70, 0x0020, 1); + /* clear wake# */ + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1b71, 0x0001, 1); + /* wait ~2.5ms */ + usleep_range(2500, 3000); + /* set mode wake# output follows the combination logic directly */ + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1b71, 0x0020, 1); + /* clear interrupts status */ + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x130f, 1); + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x1b7b, 1); + /* enable interrupt */ + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1320, 0x03, 1); + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1b79, 0x00, 1); + + mutex_unlock(&spec->cs8409_i2c_mux); + + return 0; +} + +/* enable and run cs42l42 slave codec jack auto detect */ +static void cs8409_cs42l42_run_jack_detect(struct hda_codec *codec) +{ + struct cs_spec *spec = codec->spec; + + mutex_lock(&spec->cs8409_i2c_mux); + + /* clear interrupts */ + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x1308, 1); + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x1b77, 1); + + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1102, 0x87, 1); + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1f06, 0x86, 1); + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1b74, 0x07, 1); + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x131b, 0x01, 1); + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1120, 0x80, 1); + /* wait ~110ms*/ + usleep_range(110000, 200000); + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x111f, 0x77, 1); + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1120, 0xc0, 1); + /* wait ~10ms */ + usleep_range(10000, 25000); + + mutex_unlock(&spec->cs8409_i2c_mux); + + struct cs_spec *spec = codec->spec; + + mutex_lock(&spec->cs8409_i2c_mux); + mutex_unlock(&spec->cs8409_i2c_mux); + +} + +/* + * in the case of cs8409 we do not have unsolicited events from nid's 0x24 + * and 0x34 where hs mic and hp are connected. companion codec cs42l42 will + * generate interrupt via gpio 4 to notify jack events. we have to overwrite + * generic snd_hda_jack_unsol_event(), read cs42l42 jack detect status registers + * and then notify status via generic snd_hda_jack_unsol_event() call. + */ +static void cs8409_jack_unsol_event(struct hda_codec *codec, unsigned int res) +{ + struct cs_spec *spec = codec->spec; + int status_changed = 0; + unsigned int reg_cdc_status = 0; + unsigned int reg_hs_status = 0; + unsigned int reg_ts_status = 0; + int type = 0; + struct hda_jack_tbl *jk; + + /* jack_unsol_event() will be called every time gpio line changing state. + * in this case gpio4 line goes up as a result of reading interrupt status + * registers in previous cs8409_jack_unsol_event() call. + * we don't need to handle this event, ignoring... + */ + if ((res & (1 << 4))) + return; + + mutex_lock(&spec->cs8409_i2c_mux); + + /* read jack detect status registers */ + reg_cdc_status = cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x1308, 1); + reg_hs_status = cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x1124, 1); + reg_ts_status = cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x130f, 1); + + /* clear interrupts */ + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x1b7b, 1); + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x1308, 1); + cs8409_i2c_read(codec, cs42l42_i2c_addr, 0x130f, 1); + + mutex_unlock(&spec->cs8409_i2c_mux); + + /* hsdet_auto_done */ + if (reg_cdc_status & cs42l42_hsdet_auto_done) { + + type = ((reg_hs_status & cs42l42_hstype_mask) + 1); + /* cs42l42 reports optical jack as type 4 + * we don't handle optical jack + */ + if (type != 4) { + if (!spec->cs42l42_hp_jack_in) { + status_changed = 1; + spec->cs42l42_hp_jack_in = 1; + } + /* type = 3 has no mic */ + if ((!spec->cs42l42_mic_jack_in) && (type != 3)) { + status_changed = 1; + spec->cs42l42_mic_jack_in = 1; + } + } else { + if (spec->cs42l42_hp_jack_in || spec->cs42l42_mic_jack_in) { + status_changed = 1; + spec->cs42l42_hp_jack_in = 0; + spec->cs42l42_mic_jack_in = 0; + } + } + + } else { + /* tip_sense insert/remove */ + switch (reg_ts_status) { + case cs42l42_jack_inserted: + cs8409_cs42l42_run_jack_detect(codec); + break; + + case cs42l42_jack_removed: + if (spec->cs42l42_hp_jack_in || spec->cs42l42_mic_jack_in) { + status_changed = 1; + spec->cs42l42_hp_jack_in = 0; + spec->cs42l42_mic_jack_in = 0; + } + break; + + default: + /* jack in transition */ + status_changed = 0; + break; + } + } + + if (status_changed) { + + snd_hda_set_pin_ctl(codec, cs8409_cs42l42_spk_pin_nid, + (spec->cs42l42_hp_jack_in)?0 : pin_out); + + /* report jack*/ + jk = snd_hda_jack_tbl_get_mst(codec, cs8409_cs42l42_hp_pin_nid, 0); + if (jk) { + snd_hda_jack_unsol_event(codec, + (jk->tag << ac_unsol_res_tag_shift) & ac_unsol_res_tag); + } + /* report jack*/ + jk = snd_hda_jack_tbl_get_mst(codec, cs8409_cs42l42_amic_pin_nid, 0); + if (jk) { + snd_hda_jack_unsol_event(codec, + (jk->tag << ac_unsol_res_tag_shift) & ac_unsol_res_tag); + } + } + /* run jack auto detect first time on boot + * after controls have been added, to check if jack has + * been already plugged in + */ + cs8409_cs42l42_run_jack_detect(codec); + usleep_range(100000, 150000); + + struct cs_spec *spec = codec->spec; + + mutex_lock(&spec->cs8409_i2c_mux); + /* power down cs42l42 asp/eq/mix/hp */ + cs8409_i2c_write(codec, cs42l42_i2c_addr, 0x1101, 0xfe, 1); + mutex_unlock(&spec->cs8409_i2c_mux); + + +static void cs8409_cs42l42_cap_sync_hook(struct hda_codec *codec, + struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct cs_spec *spec = codec->spec; + unsigned int curval, expval; + /* cs8409 dmic pin only allows the setting of the stream parameters in + * power state d0. when a headset is unplugged, and the path is switched to + * the dmic, the stream is restarted with the new adc, but this is done in + * power state d3. restart the stream now dmic is in d0. + */ + if (spec->gen.cur_adc == cs8409_cs42l42_dmic_adc_pin_nid) { + curval = snd_hda_codec_read(codec, spec->gen.cur_adc, + 0, ac_verb_get_conv, 0); + expval = (spec->gen.cur_adc_stream_tag << 4) | 0; + if (curval != expval) { + codec_dbg(codec, "%s restarting stream after dmic switch ", __func__); + __snd_hda_codec_cleanup_stream(codec, spec->gen.cur_adc, 1); + snd_hda_codec_setup_stream(codec, spec->gen.cur_adc, + spec->gen.cur_adc_stream_tag, 0, + spec->gen.cur_adc_format); + } + } +} + +/* enable/disable unsolicited response for gpio(s) 3,4 */ +static void cs8409_enable_ur(struct hda_codec *codec, int flag) +{ + /* gpio4 int# and gpio3 wake# */ + snd_hda_codec_write(codec, codec->core.afg, + 0, ac_verb_set_gpio_unsolicited_rsp_mask, + flag?(gpio3_int | gpio4_int) : 0); + + snd_hda_codec_write(codec, codec->core.afg, + 0, ac_verb_set_unsolicited_enable, + flag?ac_unsol_enabled : 0); + +} + + /* disable unsolicited response during boot */ + cs8409_enable_ur(codec, 0); + + mutex_lock(&spec->cs8409_i2c_mux); + mutex_unlock(&spec->cs8409_i2c_mux); + cs8409_cs42l42_enable_jack_detect(codec); + + /* enable unsolicited response */ + cs8409_enable_ur(codec, 1); + + cs8409_cs42l42_run_jack_detect(codec); + usleep_range(100000, 150000); - .unsol_event = snd_hda_jack_unsol_event, + .unsol_event = cs8409_jack_unsol_event, +static int cs8409_cs42l42_exec_verb(struct hdac_device *dev, + unsigned int cmd, unsigned int flags, unsigned int *res) +{ + struct hda_codec *codec = container_of(dev, struct hda_codec, core); + struct cs_spec *spec = codec->spec; + + unsigned int nid = 0; + unsigned int verb = 0; + + nid = ((cmd >> 20) & 0x07f); + verb = ((cmd >> 8) & 0x0fff); + + /* cs8409 pins have no ac_pinsense_presence + * capabilities. we have to intercept 2 calls for pins 0x24 and 0x34 + * and return correct pin sense values for read_pin_sense() call from + * hda_jack based on cs42l42 jack detect status. + */ + switch (nid) { + case cs8409_cs42l42_hp_pin_nid: + if (verb == ac_verb_get_pin_sense) { + *res = (spec->cs42l42_hp_jack_in) ? ac_pinsense_presence : 0; + return 0; + } + break; + + case cs8409_cs42l42_amic_pin_nid: + if (verb == ac_verb_get_pin_sense) { + *res = (spec->cs42l42_mic_jack_in) ? ac_pinsense_presence : 0; + return 0; + } + break; + + default: + break; + } + + return spec->exec_verb(dev, cmd, flags, res); +} + + /* verb exec op override */ + spec->exec_verb = codec->core.exec_verb; + codec->core.exec_verb = cs8409_cs42l42_exec_verb; + + mutex_init(&spec->cs8409_i2c_mux); + + spec->gen.cap_sync_hook = cs8409_cs42l42_cap_sync_hook; + + spec->cs42l42_hp_jack_in = 0; + spec->cs42l42_mic_jack_in = 0; +
|
Audio
|
b73df04187ebb52edf3f7e502bb245c5ccab2763
|
vitaly rodionov
|
sound
|
pci
|
hda
|
alsa: hda/cirrus: add headphone and headset mic volume control
|
cs8409 does not support volume control for nids 0x24 (the headphones), or 0x34 (the headset mic). however, cs42l42 codec does support gain control for both. we can add support for volume controls, by writing the the cs42l42 regmap via i2c commands, using custom info, get and put volume functions, saved in the control.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for cs8409 hda bridge and cs42l42 companion codec
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['hda ', 'cirrus']
|
['c']
| 1
| 200
| 0
|
--- diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c +#define cs42l42_hp_ch (2u) +#define cs42l42_hs_mic_ch (1u) + + unsigned int cs42l42_volume_init:1; + char cs42l42_hp_volume[cs42l42_hp_ch]; + char cs42l42_hs_mic_volume[cs42l42_hs_mic_ch]; +#define cs8409_cs42l42_hp_vol_real_min (-63) +#define cs8409_cs42l42_hp_vol_real_max (0) +#define cs8409_cs42l42_amic_vol_real_min (-97) +#define cs8409_cs42l42_amic_vol_real_max (12) +#define cs8409_cs42l42_reg_hs_volume_cha (0x2301) +#define cs8409_cs42l42_reg_hs_volume_chb (0x2303) +#define cs8409_cs42l42_reg_amic_volume (0x1d03) + +static int cs8409_cs42l42_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + u16 nid = get_amp_nid(kcontrol); + u8 chs = get_amp_channels(kcontrol); + + codec_dbg(codec, "%s() nid: %d ", __func__, nid); + switch (nid) { + case cs8409_cs42l42_hp_pin_nid: + uinfo->type = sndrv_ctl_elem_type_integer; + uinfo->count = chs == 3 ? 2 : 1; + uinfo->value.integer.min = cs8409_cs42l42_hp_vol_real_min; + uinfo->value.integer.max = cs8409_cs42l42_hp_vol_real_max; + break; + case cs8409_cs42l42_amic_pin_nid: + uinfo->type = sndrv_ctl_elem_type_integer; + uinfo->count = chs == 3 ? 2 : 1; + uinfo->value.integer.min = cs8409_cs42l42_amic_vol_real_min; + uinfo->value.integer.max = cs8409_cs42l42_amic_vol_real_max; + break; + default: + break; + } + return 0; +} + +static void cs8409_cs42l42_update_volume(struct hda_codec *codec) +{ + struct cs_spec *spec = codec->spec; + + mutex_lock(&spec->cs8409_i2c_mux); + spec->cs42l42_hp_volume[0] = -(cs8409_i2c_read(codec, cs42l42_i2c_addr, + cs8409_cs42l42_reg_hs_volume_cha, 1)); + spec->cs42l42_hp_volume[1] = -(cs8409_i2c_read(codec, cs42l42_i2c_addr, + cs8409_cs42l42_reg_hs_volume_chb, 1)); + spec->cs42l42_hs_mic_volume[0] = -(cs8409_i2c_read(codec, cs42l42_i2c_addr, + cs8409_cs42l42_reg_amic_volume, 1)); + mutex_unlock(&spec->cs8409_i2c_mux); + spec->cs42l42_volume_init = 1; +} + +static int cs8409_cs42l42_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct cs_spec *spec = codec->spec; + hda_nid_t nid = get_amp_nid(kcontrol); + int chs = get_amp_channels(kcontrol); + long *valp = ucontrol->value.integer.value; + + if (!spec->cs42l42_volume_init) { + snd_hda_power_up(codec); + cs8409_cs42l42_update_volume(codec); + snd_hda_power_down(codec); + } + switch (nid) { + case cs8409_cs42l42_hp_pin_nid: + if (chs & 1) + *valp++ = spec->cs42l42_hp_volume[0]; + if (chs & 2) + *valp++ = spec->cs42l42_hp_volume[1]; + break; + case cs8409_cs42l42_amic_pin_nid: + if (chs & 1) + *valp++ = spec->cs42l42_hs_mic_volume[0]; + break; + default: + break; + } + return 0; +} + +static int cs8409_cs42l42_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct cs_spec *spec = codec->spec; + hda_nid_t nid = get_amp_nid(kcontrol); + int chs = get_amp_channels(kcontrol); + long *valp = ucontrol->value.integer.value; + int change = 0; + char vol = 0; + + snd_hda_power_up(codec); + switch (nid) { + case cs8409_cs42l42_hp_pin_nid: + mutex_lock(&spec->cs8409_i2c_mux); + if (chs & 1) { + vol = -(*valp); + change = cs8409_i2c_write(codec, cs42l42_i2c_addr, + cs8409_cs42l42_reg_hs_volume_cha, vol, 1); + valp++; + } + if (chs & 2) { + vol = -(*valp); + change |= cs8409_i2c_write(codec, cs42l42_i2c_addr, + cs8409_cs42l42_reg_hs_volume_chb, vol, 1); + } + mutex_unlock(&spec->cs8409_i2c_mux); + break; + case cs8409_cs42l42_amic_pin_nid: + mutex_lock(&spec->cs8409_i2c_mux); + if (chs & 1) { + change = cs8409_i2c_write( + codec, cs42l42_i2c_addr, + cs8409_cs42l42_reg_amic_volume, (char)*valp, 1); + valp++; + } + mutex_unlock(&spec->cs8409_i2c_mux); + break; + default: + break; + } + cs8409_cs42l42_update_volume(codec); + snd_hda_power_down(codec); + return change; +} + +static const declare_tlv_db_scale( + cs8409_cs42l42_hp_db_scale, + cs8409_cs42l42_hp_vol_real_min * 100, 100, 1); + +static const declare_tlv_db_scale( + cs8409_cs42l42_amic_db_scale, + cs8409_cs42l42_amic_vol_real_min * 100, 100, 1); + +static const struct snd_kcontrol_new cs8409_cs42l42_hp_volume_mixer = { + .iface = sndrv_ctl_elem_iface_mixer, + .index = 0, + .name = "headphone playback volume", + .subdevice = (hda_subdev_amp_flag | hda_subdev_nid_flag), + .access = (sndrv_ctl_elem_access_readwrite + | sndrv_ctl_elem_access_tlv_read), + .info = cs8409_cs42l42_volume_info, + .get = cs8409_cs42l42_volume_get, + .put = cs8409_cs42l42_volume_put, + .tlv = { .p = cs8409_cs42l42_hp_db_scale }, + .private_value = hda_compose_amp_val( + cs8409_cs42l42_hp_pin_nid, 3, 0, hda_output) + | hda_amp_val_min_mute +}; + +static const struct snd_kcontrol_new cs8409_cs42l42_amic_volume_mixer = { + .iface = sndrv_ctl_elem_iface_mixer, + .index = 0, + .name = "headset mic capture volume", + .subdevice = (hda_subdev_amp_flag | hda_subdev_nid_flag), + .access = (sndrv_ctl_elem_access_readwrite + | sndrv_ctl_elem_access_tlv_read), + .info = cs8409_cs42l42_volume_info, + .get = cs8409_cs42l42_volume_get, + .put = cs8409_cs42l42_volume_put, + .tlv = { .p = cs8409_cs42l42_amic_db_scale }, + .private_value = hda_compose_amp_val( + cs8409_cs42l42_amic_pin_nid, 1, 0, hda_input) + | hda_amp_val_min_mute +}; + + /* restore volumes after resume */ + if (spec->cs42l42_volume_init) { + mutex_lock(&spec->cs8409_i2c_mux); + cs8409_i2c_write(codec, cs42l42_i2c_addr, + cs8409_cs42l42_reg_hs_volume_cha, -spec->cs42l42_hp_volume[0], + 1); + cs8409_i2c_write(codec, cs42l42_i2c_addr, + cs8409_cs42l42_reg_hs_volume_chb, -spec->cs42l42_hp_volume[1], + 1); + cs8409_i2c_write( + codec, cs42l42_i2c_addr, + cs8409_cs42l42_reg_amic_volume, spec->cs42l42_hs_mic_volume[0], + 1); + mutex_unlock(&spec->cs8409_i2c_mux); + } + + cs8409_cs42l42_update_volume(codec); + + if (!snd_hda_gen_add_kctl( + &spec->gen, null, &cs8409_cs42l42_hp_volume_mixer)) + return -1; + + if (!snd_hda_gen_add_kctl( + &spec->gen, null, &cs8409_cs42l42_amic_volume_mixer)) + return -1; + + spec->gen.suppress_vmaster = 1;
|
Audio
|
b9dd23bb03fe241ccb774c59b05d5cbac07895dc
|
stefan binding
|
sound
|
pci
|
hda
|
alsa: hda - bind headset buttons to the headphone jack
|
with the hda driver, if the headset buttons are supported, an audio jack will be created for them. this audio jack is a bit confusing to users since it can't report headphone/mic insertion events but it claims to support these events.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
bind headset buttons to the headphone jack
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['hda ']
|
['h', 'c']
| 3
| 91
| 5
|
--- diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c +/** + * snd_hda_jack_bind_keymap - bind keys generated from one nid to another jack. + * @codec: the hda codec + * @key_nid: key event is generated by this pin nid + * @keymap: map of key type and key code + * @jack_nid: key reports to the jack of this pin nid + * + * this function is used in the case of key is generated from one nid while is + * reported to the jack of another nid. + */ +int snd_hda_jack_bind_keymap(struct hda_codec *codec, hda_nid_t key_nid, + const struct hda_jack_keymap *keymap, + hda_nid_t jack_nid) +{ + const struct hda_jack_keymap *map; + struct hda_jack_tbl *key_gen = snd_hda_jack_tbl_get(codec, key_nid); + struct hda_jack_tbl *report_to = snd_hda_jack_tbl_get(codec, jack_nid); + + warn_on(codec->dp_mst); + + if (!key_gen || !report_to || !report_to->jack) + return -einval; + + key_gen->key_report_jack = jack_nid; + + if (keymap) + for (map = keymap; map->type; map++) + snd_jack_set_key(report_to->jack, map->type, map->key); + + return 0; +} +export_symbol_gpl(snd_hda_jack_bind_keymap); + +/** + * snd_hda_jack_set_button_state - report button event to the hda_jack_tbl button_state. + * @codec: the hda codec + * @jack_nid: the button event reports to the jack_tbl of this nid + * @button_state: the button event captured by codec + * + * codec driver calls this function to report the button event. + */ +void snd_hda_jack_set_button_state(struct hda_codec *codec, hda_nid_t jack_nid, + int button_state) +{ + struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, jack_nid); + + if (!jack) + return; + + if (jack->key_report_jack) { + struct hda_jack_tbl *report_to = + snd_hda_jack_tbl_get(codec, jack->key_report_jack); + + if (report_to) { + report_to->button_state = button_state; + return; + } + } + + jack->button_state = button_state; +} +export_symbol_gpl(snd_hda_jack_set_button_state); + - event->jack_dirty = 1; + + if (event->key_report_jack) { + struct hda_jack_tbl *report_to = + snd_hda_jack_tbl_get_mst(codec, event->key_report_jack, + event->dev_id); + if (report_to) + report_to->jack_dirty = 1; + } else + event->jack_dirty = 1; diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h --- a/sound/pci/hda/hda_jack.h +++ b/sound/pci/hda/hda_jack.h + hda_nid_t key_report_jack; /* key reports to this jack */ +int snd_hda_jack_bind_keymap(struct hda_codec *codec, hda_nid_t key_nid, + const struct hda_jack_keymap *keymap, + hda_nid_t jack_nid); + +void snd_hda_jack_set_button_state(struct hda_codec *codec, hda_nid_t jack_nid, + int button_state); + diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c - jack->jack->button_state = report; + snd_hda_jack_set_button_state(codec, jack->nid, report); + hda_nid_t hp_pin; - snd_hda_jack_add_kctl(codec, 0x55, "headset jack", false, - snd_jack_headset, alc_headset_btn_keymap); - case hda_fixup_act_init: + case hda_fixup_act_build: + hp_pin = alc_get_hp_pin(spec); + if (!hp_pin || snd_hda_jack_bind_keymap(codec, 0x55, + alc_headset_btn_keymap, + hp_pin)) + snd_hda_jack_add_kctl(codec, 0x55, "headset jack", + false, snd_jack_headset, + alc_headset_btn_keymap); +
|
Audio
|
04f7791b7a4ba6ff3f53b3f3978b353924d10e78
|
hui wang
|
sound
|
pci
|
hda
|
alsa: hda/realtek: enable mute/micmute leds and limit mic boost on elitebook 845 g8
|
on hp elitebook 845 g8, the audio leds can be enabled by alc285_fixup_hp_mute_led. so use it accordingly.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
enable mute/micmute leds and limit mic boost on
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['hda ', 'realtek']
|
['c']
| 1
| 8
| 0
|
--- diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c + alc285_fixup_hp_limit_int_mic_boost, + [alc285_fixup_hp_limit_int_mic_boost] = { + .type = hda_fixup_func, + .v.func = alc269_fixup_limit_int_mic_boost, + .chained = true, + .chain_id = alc285_fixup_hp_mute_led, + }, + snd_pci_quirk(0x103c, 0x8898, "hp elitebook 845 g8 notebook pc", alc285_fixup_hp_limit_int_mic_boost),
|
Audio
|
bd15b15523fd3197d1bb46403e02e92877a4f412
|
kai heng feng
|
sound
|
pci
|
hda
|
alsa: hda: add alderlake-m pci id
|
add hd audio pci id for intel alderlake-m. add rules to snd_intel_dsp_find_config() to choose sof driver for adl-m systems with pch-dmic or soundwire codecs, and legacy driver for the rest.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add alderlake-m pci id
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['hda ']
|
['c']
| 2
| 7
| 0
|
--- diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c --- a/sound/hda/intel-dsp-config.c +++ b/sound/hda/intel-dsp-config.c + { + .flags = flag_sof | flag_sof_only_if_dmic_or_soundwire, + .device = 0x51cc, + }, diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c + /* alderlake-m */ + { pci_device(0x8086, 0x51cc), + .driver_data = azx_driver_skl | azx_dcaps_intel_skylake},
|
Audio
|
4ad7935df6a566225c3d51900bde8f2f0f8b6de3
|
kai vehmanen p ter ujfalusi peter ujfalusi intel com ranjani sridharan ranjani sridharan linux intel com pierre louis bossart pierre louis bossart linux intel com
|
sound
|
hda
|
hda
|
alsa: usb-audio: add db range mapping for sennheiser communications headset pc 8
|
the decibel volume range contains a negative maximum value resulting in pipewire complaining about the device and effectivly having no sound output. the wrong values also resulted in the headset sounding muted already at a mixer level of about ~25%.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add db range mapping for sennheiser communications headset pc 8
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['usb-audio']
|
['c']
| 1
| 12
| 0
|
--- diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c --- a/sound/usb/mixer_maps.c +++ b/sound/usb/mixer_maps.c +/* sennheiser communications headset [pc 8], the db value is reported as -6 negative maximum */ +static const struct usbmix_db_map sennheiser_pc8_db = {-9500, 0}; +static const struct usbmix_name_map sennheiser_pc8_map[] = { + { 9, null, .db = &sennheiser_pc8_db }, + { 0 } /* terminator */ +}; + + { + /* sennheiser communications headset [pc 8] */ + .id = usb_id(0x1395, 0x0025), + .map = sennheiser_pc8_map, + },
|
Audio
|
ab2165e2e6ed17345ffa8ee88ca764e8788ebcd7
|
timo gurr
|
sound
|
usb
| |
uapi: virtio_ids: add a sound device type id from oasis spec
|
the oasis virtio spec defines a sound device type id that is not present in the header yet.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
(featured) add virtio sound driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h']
| 1
| 1
| 0
|
--- diff --git a/include/uapi/linux/virtio_ids.h b/include/uapi/linux/virtio_ids.h --- a/include/uapi/linux/virtio_ids.h +++ b/include/uapi/linux/virtio_ids.h +#define virtio_id_sound 25 /* virtio sound */
|
Audio
|
0ae0337f929a970ee8d83e0e95e6b8d05562ce3b
|
anton yakovlev
|
include
|
uapi
|
linux
|
alsa: virtio: add virtio sound driver
|
introduce skeleton of the virtio sound driver. the driver implements the virtio sound device specification, which has become part of the virtio standard.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
(featured) add virtio sound driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['c', 'h', 'kconfig', 'maintainers', 'makefile']
| 8
| 753
| 1
|
--- diff --git a/maintainers b/maintainers --- a/maintainers +++ b/maintainers +virtio sound driver +m: anton yakovlev <anton.yakovlev@opensynergy.com> +m: "michael s. tsirkin" <mst@redhat.com> +l: virtualization@lists.linux-foundation.org +l: alsa-devel@alsa-project.org (moderated for non-subscribers) +s: maintained +f: include/uapi/linux/virtio_snd.h +f: sound/virtio/* + diff --git a/include/uapi/linux/virtio_snd.h b/include/uapi/linux/virtio_snd.h --- /dev/null +++ b/include/uapi/linux/virtio_snd.h +/* spdx-license-identifier: bsd-3-clause */ +/* + * copyright (c) 2021 opensynergy gmbh + */ +#ifndef virtio_snd_if_h +#define virtio_snd_if_h + +#include <linux/virtio_types.h> + +/******************************************************************************* + * configuration space + */ +struct virtio_snd_config { + /* # of available physical jacks */ + __le32 jacks; + /* # of available pcm streams */ + __le32 streams; + /* # of available channel maps */ + __le32 chmaps; +}; + +enum { + /* device virtqueue indexes */ + virtio_snd_vq_control = 0, + virtio_snd_vq_event, + virtio_snd_vq_tx, + virtio_snd_vq_rx, + /* # of device virtqueues */ + virtio_snd_vq_max +}; + +/******************************************************************************* + * common definitions + */ + +/* supported dataflow directions */ +enum { + virtio_snd_d_output = 0, + virtio_snd_d_input +}; + +enum { + /* jack control request types */ + virtio_snd_r_jack_info = 1, + virtio_snd_r_jack_remap, + + /* pcm control request types */ + virtio_snd_r_pcm_info = 0x0100, + virtio_snd_r_pcm_set_params, + virtio_snd_r_pcm_prepare, + virtio_snd_r_pcm_release, + virtio_snd_r_pcm_start, + virtio_snd_r_pcm_stop, + + /* channel map control request types */ + virtio_snd_r_chmap_info = 0x0200, + + /* jack event types */ + virtio_snd_evt_jack_connected = 0x1000, + virtio_snd_evt_jack_disconnected, + + /* pcm event types */ + virtio_snd_evt_pcm_period_elapsed = 0x1100, + virtio_snd_evt_pcm_xrun, + + /* common status codes */ + virtio_snd_s_ok = 0x8000, + virtio_snd_s_bad_msg, + virtio_snd_s_not_supp, + virtio_snd_s_io_err +}; + +/* common header */ +struct virtio_snd_hdr { + __le32 code; +}; + +/* event notification */ +struct virtio_snd_event { + /* virtio_snd_evt_xxx */ + struct virtio_snd_hdr hdr; + /* optional event data */ + __le32 data; +}; + +/* common control request to query an item information */ +struct virtio_snd_query_info { + /* virtio_snd_r_xxx_info */ + struct virtio_snd_hdr hdr; + /* item start identifier */ + __le32 start_id; + /* item count to query */ + __le32 count; + /* item information size in bytes */ + __le32 size; +}; + +/* common item information header */ +struct virtio_snd_info { + /* function group node id (high definition audio specification 7.1.2) */ + __le32 hda_fn_nid; +}; + +/******************************************************************************* + * jack control messages + */ +struct virtio_snd_jack_hdr { + /* virtio_snd_r_jack_xxx */ + struct virtio_snd_hdr hdr; + /* 0 ... virtio_snd_config::jacks - 1 */ + __le32 jack_id; +}; + +/* supported jack features */ +enum { + virtio_snd_jack_f_remap = 0 +}; + +struct virtio_snd_jack_info { + /* common header */ + struct virtio_snd_info hdr; + /* supported feature bit map (1 << virtio_snd_jack_f_xxx) */ + __le32 features; + /* pin configuration (high definition audio specification 7.3.3.31) */ + __le32 hda_reg_defconf; + /* pin capabilities (high definition audio specification 7.3.4.9) */ + __le32 hda_reg_caps; + /* current jack connection status (0: disconnected, 1: connected) */ + __u8 connected; + + __u8 padding[7]; +}; + +/* jack remapping control request */ +struct virtio_snd_jack_remap { + /* .code = virtio_snd_r_jack_remap */ + struct virtio_snd_jack_hdr hdr; + /* selected association number */ + __le32 association; + /* selected sequence number */ + __le32 sequence; +}; + +/******************************************************************************* + * pcm control messages + */ +struct virtio_snd_pcm_hdr { + /* virtio_snd_r_pcm_xxx */ + struct virtio_snd_hdr hdr; + /* 0 ... virtio_snd_config::streams - 1 */ + __le32 stream_id; +}; + +/* supported pcm stream features */ +enum { + virtio_snd_pcm_f_shmem_host = 0, + virtio_snd_pcm_f_shmem_guest, + virtio_snd_pcm_f_msg_polling, + virtio_snd_pcm_f_evt_shmem_periods, + virtio_snd_pcm_f_evt_xruns +}; + +/* supported pcm sample formats */ +enum { + /* analog formats (width / physical width) */ + virtio_snd_pcm_fmt_ima_adpcm = 0, /* 4 / 4 bits */ + virtio_snd_pcm_fmt_mu_law, /* 8 / 8 bits */ + virtio_snd_pcm_fmt_a_law, /* 8 / 8 bits */ + virtio_snd_pcm_fmt_s8, /* 8 / 8 bits */ + virtio_snd_pcm_fmt_u8, /* 8 / 8 bits */ + virtio_snd_pcm_fmt_s16, /* 16 / 16 bits */ + virtio_snd_pcm_fmt_u16, /* 16 / 16 bits */ + virtio_snd_pcm_fmt_s18_3, /* 18 / 24 bits */ + virtio_snd_pcm_fmt_u18_3, /* 18 / 24 bits */ + virtio_snd_pcm_fmt_s20_3, /* 20 / 24 bits */ + virtio_snd_pcm_fmt_u20_3, /* 20 / 24 bits */ + virtio_snd_pcm_fmt_s24_3, /* 24 / 24 bits */ + virtio_snd_pcm_fmt_u24_3, /* 24 / 24 bits */ + virtio_snd_pcm_fmt_s20, /* 20 / 32 bits */ + virtio_snd_pcm_fmt_u20, /* 20 / 32 bits */ + virtio_snd_pcm_fmt_s24, /* 24 / 32 bits */ + virtio_snd_pcm_fmt_u24, /* 24 / 32 bits */ + virtio_snd_pcm_fmt_s32, /* 32 / 32 bits */ + virtio_snd_pcm_fmt_u32, /* 32 / 32 bits */ + virtio_snd_pcm_fmt_float, /* 32 / 32 bits */ + virtio_snd_pcm_fmt_float64, /* 64 / 64 bits */ + /* digital formats (width / physical width) */ + virtio_snd_pcm_fmt_dsd_u8, /* 8 / 8 bits */ + virtio_snd_pcm_fmt_dsd_u16, /* 16 / 16 bits */ + virtio_snd_pcm_fmt_dsd_u32, /* 32 / 32 bits */ + virtio_snd_pcm_fmt_iec958_subframe /* 32 / 32 bits */ +}; + +/* supported pcm frame rates */ +enum { + virtio_snd_pcm_rate_5512 = 0, + virtio_snd_pcm_rate_8000, + virtio_snd_pcm_rate_11025, + virtio_snd_pcm_rate_16000, + virtio_snd_pcm_rate_22050, + virtio_snd_pcm_rate_32000, + virtio_snd_pcm_rate_44100, + virtio_snd_pcm_rate_48000, + virtio_snd_pcm_rate_64000, + virtio_snd_pcm_rate_88200, + virtio_snd_pcm_rate_96000, + virtio_snd_pcm_rate_176400, + virtio_snd_pcm_rate_192000, + virtio_snd_pcm_rate_384000 +}; + +struct virtio_snd_pcm_info { + /* common header */ + struct virtio_snd_info hdr; + /* supported feature bit map (1 << virtio_snd_pcm_f_xxx) */ + __le32 features; + /* supported sample format bit map (1 << virtio_snd_pcm_fmt_xxx) */ + __le64 formats; + /* supported frame rate bit map (1 << virtio_snd_pcm_rate_xxx) */ + __le64 rates; + /* dataflow direction (virtio_snd_d_xxx) */ + __u8 direction; + /* minimum # of supported channels */ + __u8 channels_min; + /* maximum # of supported channels */ + __u8 channels_max; + + __u8 padding[5]; +}; + +/* set pcm stream format */ +struct virtio_snd_pcm_set_params { + /* .code = virtio_snd_r_pcm_set_params */ + struct virtio_snd_pcm_hdr hdr; + /* size of the hardware buffer */ + __le32 buffer_bytes; + /* size of the hardware period */ + __le32 period_bytes; + /* selected feature bit map (1 << virtio_snd_pcm_f_xxx) */ + __le32 features; + /* selected # of channels */ + __u8 channels; + /* selected sample format (virtio_snd_pcm_fmt_xxx) */ + __u8 format; + /* selected frame rate (virtio_snd_pcm_rate_xxx) */ + __u8 rate; + + __u8 padding; +}; + +/******************************************************************************* + * pcm i/o messages + */ + +/* i/o request header */ +struct virtio_snd_pcm_xfer { + /* 0 ... virtio_snd_config::streams - 1 */ + __le32 stream_id; +}; + +/* i/o request status */ +struct virtio_snd_pcm_status { + /* virtio_snd_s_xxx */ + __le32 status; + /* current device latency */ + __le32 latency_bytes; +}; + +/******************************************************************************* + * channel map control messages + */ +struct virtio_snd_chmap_hdr { + /* virtio_snd_r_chmap_xxx */ + struct virtio_snd_hdr hdr; + /* 0 ... virtio_snd_config::chmaps - 1 */ + __le32 chmap_id; +}; + +/* standard channel position definition */ +enum { + virtio_snd_chmap_none = 0, /* undefined */ + virtio_snd_chmap_na, /* silent */ + virtio_snd_chmap_mono, /* mono stream */ + virtio_snd_chmap_fl, /* front left */ + virtio_snd_chmap_fr, /* front right */ + virtio_snd_chmap_rl, /* rear left */ + virtio_snd_chmap_rr, /* rear right */ + virtio_snd_chmap_fc, /* front center */ + virtio_snd_chmap_lfe, /* low frequency (lfe) */ + virtio_snd_chmap_sl, /* side left */ + virtio_snd_chmap_sr, /* side right */ + virtio_snd_chmap_rc, /* rear center */ + virtio_snd_chmap_flc, /* front left center */ + virtio_snd_chmap_frc, /* front right center */ + virtio_snd_chmap_rlc, /* rear left center */ + virtio_snd_chmap_rrc, /* rear right center */ + virtio_snd_chmap_flw, /* front left wide */ + virtio_snd_chmap_frw, /* front right wide */ + virtio_snd_chmap_flh, /* front left high */ + virtio_snd_chmap_fch, /* front center high */ + virtio_snd_chmap_frh, /* front right high */ + virtio_snd_chmap_tc, /* top center */ + virtio_snd_chmap_tfl, /* top front left */ + virtio_snd_chmap_tfr, /* top front right */ + virtio_snd_chmap_tfc, /* top front center */ + virtio_snd_chmap_trl, /* top rear left */ + virtio_snd_chmap_trr, /* top rear right */ + virtio_snd_chmap_trc, /* top rear center */ + virtio_snd_chmap_tflc, /* top front left center */ + virtio_snd_chmap_tfrc, /* top front right center */ + virtio_snd_chmap_tsl, /* top side left */ + virtio_snd_chmap_tsr, /* top side right */ + virtio_snd_chmap_llfe, /* left lfe */ + virtio_snd_chmap_rlfe, /* right lfe */ + virtio_snd_chmap_bc, /* bottom center */ + virtio_snd_chmap_blc, /* bottom left center */ + virtio_snd_chmap_brc /* bottom right center */ +}; + +/* maximum possible number of channels */ +#define virtio_snd_chmap_max_size 18 + +struct virtio_snd_chmap_info { + /* common header */ + struct virtio_snd_info hdr; + /* dataflow direction (virtio_snd_d_xxx) */ + __u8 direction; + /* # of valid channel position values */ + __u8 channels; + /* channel position values (virtio_snd_chmap_xxx) */ + __u8 positions[virtio_snd_chmap_max_size]; +}; + +#endif /* virtio_snd_if_h */ diff --git a/sound/kconfig b/sound/kconfig --- a/sound/kconfig +++ b/sound/kconfig +source "sound/virtio/kconfig" + diff --git a/sound/makefile b/sound/makefile --- a/sound/makefile +++ b/sound/makefile - firewire/ sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/ hda/ x86/ xen/ + firewire/ sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/ hda/ x86/ xen/ \ + virtio/ diff --git a/sound/virtio/kconfig b/sound/virtio/kconfig --- /dev/null +++ b/sound/virtio/kconfig +# spdx-license-identifier: gpl-2.0+ +# sound card driver for virtio + +config snd_virtio + tristate "virtio sound driver" + depends on virtio + select snd_pcm + select snd_jack + help + this is the virtual sound driver for virtio. say y or m. diff --git a/sound/virtio/makefile b/sound/virtio/makefile --- /dev/null +++ b/sound/virtio/makefile +# spdx-license-identifier: gpl-2.0+ + +obj-$(config_snd_virtio) += virtio_snd.o + +virtio_snd-objs := \ + virtio_card.o + diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c --- /dev/null +++ b/sound/virtio/virtio_card.c +// spdx-license-identifier: gpl-2.0+ +/* + * virtio-snd: virtio sound device + * copyright (c) 2021 opensynergy gmbh + */ +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/virtio_config.h> +#include <sound/initval.h> +#include <uapi/linux/virtio_ids.h> + +#include "virtio_card.h" + +static void virtsnd_remove(struct virtio_device *vdev); + +/** + * virtsnd_event_send() - add an event to the event queue. + * @vqueue: underlying event virtqueue. + * @event: event. + * @notify: indicates whether or not to send a notification to the device. + * @gfp: kernel flags for memory allocation. + * + * context: any context. + */ +static void virtsnd_event_send(struct virtqueue *vqueue, + struct virtio_snd_event *event, bool notify, + gfp_t gfp) +{ + struct scatterlist sg; + struct scatterlist *psgs[1] = { &sg }; + + /* reset event content */ + memset(event, 0, sizeof(*event)); + + sg_init_one(&sg, event, sizeof(*event)); + + if (virtqueue_add_sgs(vqueue, psgs, 0, 1, event, gfp) || !notify) + return; + + if (virtqueue_kick_prepare(vqueue)) + virtqueue_notify(vqueue); +} + +/** + * virtsnd_event_dispatch() - dispatch an event from the device side. + * @snd: virtio sound device. + * @event: virtio sound event. + * + * context: any context. + */ +static void virtsnd_event_dispatch(struct virtio_snd *snd, + struct virtio_snd_event *event) +{ +} + +/** + * virtsnd_event_notify_cb() - dispatch all reported events from the event queue. + * @vqueue: underlying event virtqueue. + * + * this callback function is called upon a vring interrupt request from the + * device. + * + * context: interrupt context. + */ +static void virtsnd_event_notify_cb(struct virtqueue *vqueue) +{ + struct virtio_snd *snd = vqueue->vdev->priv; + struct virtio_snd_queue *queue = virtsnd_event_queue(snd); + struct virtio_snd_event *event; + u32 length; + unsigned long flags; + + spin_lock_irqsave(&queue->lock, flags); + do { + virtqueue_disable_cb(vqueue); + while ((event = virtqueue_get_buf(vqueue, &length))) { + virtsnd_event_dispatch(snd, event); + virtsnd_event_send(vqueue, event, true, gfp_atomic); + } + if (unlikely(virtqueue_is_broken(vqueue))) + break; + } while (!virtqueue_enable_cb(vqueue)); + spin_unlock_irqrestore(&queue->lock, flags); +} + +/** + * virtsnd_find_vqs() - enumerate and initialize all virtqueues. + * @snd: virtio sound device. + * + * after calling this function, the event queue is disabled. + * + * context: any context. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_find_vqs(struct virtio_snd *snd) +{ + struct virtio_device *vdev = snd->vdev; + static vq_callback_t *callbacks[virtio_snd_vq_max] = { + [virtio_snd_vq_event] = virtsnd_event_notify_cb + }; + static const char *names[virtio_snd_vq_max] = { + [virtio_snd_vq_event] = "virtsnd-event" + }; + struct virtqueue *vqs[virtio_snd_vq_max] = { 0 }; + unsigned int i; + unsigned int n; + int rc; + + rc = virtio_find_vqs(vdev, virtio_snd_vq_max, vqs, callbacks, names, + null); + if (rc) { + dev_err(&vdev->dev, "failed to initialize virtqueues "); + return rc; + } + + for (i = 0; i < virtio_snd_vq_max; ++i) + snd->queues[i].vqueue = vqs[i]; + + /* allocate events and populate the event queue */ + virtqueue_disable_cb(vqs[virtio_snd_vq_event]); + + n = virtqueue_get_vring_size(vqs[virtio_snd_vq_event]); + + snd->event_msgs = kmalloc_array(n, sizeof(*snd->event_msgs), + gfp_kernel); + if (!snd->event_msgs) + return -enomem; + + for (i = 0; i < n; ++i) + virtsnd_event_send(vqs[virtio_snd_vq_event], + &snd->event_msgs[i], false, gfp_kernel); + + return 0; +} + +/** + * virtsnd_enable_event_vq() - enable the event virtqueue. + * @snd: virtio sound device. + * + * context: any context. + */ +static void virtsnd_enable_event_vq(struct virtio_snd *snd) +{ + struct virtio_snd_queue *queue = virtsnd_event_queue(snd); + + if (!virtqueue_enable_cb(queue->vqueue)) + virtsnd_event_notify_cb(queue->vqueue); +} + +/** + * virtsnd_disable_event_vq() - disable the event virtqueue. + * @snd: virtio sound device. + * + * context: any context. + */ +static void virtsnd_disable_event_vq(struct virtio_snd *snd) +{ + struct virtio_snd_queue *queue = virtsnd_event_queue(snd); + struct virtio_snd_event *event; + u32 length; + unsigned long flags; + + if (queue->vqueue) { + spin_lock_irqsave(&queue->lock, flags); + virtqueue_disable_cb(queue->vqueue); + while ((event = virtqueue_get_buf(queue->vqueue, &length))) + virtsnd_event_dispatch(snd, event); + spin_unlock_irqrestore(&queue->lock, flags); + } +} + +/** + * virtsnd_build_devs() - read configuration and build alsa devices. + * @snd: virtio sound device. + * + * context: any context that permits to sleep. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_build_devs(struct virtio_snd *snd) +{ + struct virtio_device *vdev = snd->vdev; + struct device *dev = &vdev->dev; + int rc; + + rc = snd_card_new(dev, sndrv_default_idx1, sndrv_default_str1, + this_module, 0, &snd->card); + if (rc < 0) + return rc; + + snd->card->private_data = snd; + + strscpy(snd->card->driver, virtio_snd_card_driver, + sizeof(snd->card->driver)); + strscpy(snd->card->shortname, virtio_snd_card_name, + sizeof(snd->card->shortname)); + if (dev->parent->bus) + snprintf(snd->card->longname, sizeof(snd->card->longname), + virtio_snd_card_name " at %s/%s/%s", + dev->parent->bus->name, dev_name(dev->parent), + dev_name(dev)); + else + snprintf(snd->card->longname, sizeof(snd->card->longname), + virtio_snd_card_name " at %s/%s", + dev_name(dev->parent), dev_name(dev)); + + return snd_card_register(snd->card); +} + +/** + * virtsnd_validate() - validate if the device can be started. + * @vdev: virtio parent device. + * + * context: any context. + * return: 0 on success, -einval on failure. + */ +static int virtsnd_validate(struct virtio_device *vdev) +{ + if (!vdev->config->get) { + dev_err(&vdev->dev, "configuration access disabled "); + return -einval; + } + + if (!virtio_has_feature(vdev, virtio_f_version_1)) { + dev_err(&vdev->dev, + "device does not comply with spec version 1.x "); + return -einval; + } + + return 0; +} + +/** + * virtsnd_probe() - create and initialize the device. + * @vdev: virtio parent device. + * + * context: any context that permits to sleep. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_probe(struct virtio_device *vdev) +{ + struct virtio_snd *snd; + unsigned int i; + int rc; + + snd = devm_kzalloc(&vdev->dev, sizeof(*snd), gfp_kernel); + if (!snd) + return -enomem; + + snd->vdev = vdev; + + vdev->priv = snd; + + for (i = 0; i < virtio_snd_vq_max; ++i) + spin_lock_init(&snd->queues[i].lock); + + rc = virtsnd_find_vqs(snd); + if (rc) + goto on_exit; + + virtio_device_ready(vdev); + + rc = virtsnd_build_devs(snd); + if (rc) + goto on_exit; + + virtsnd_enable_event_vq(snd); + +on_exit: + if (rc) + virtsnd_remove(vdev); + + return rc; +} + +/** + * virtsnd_remove() - remove virtio and alsa devices. + * @vdev: virtio parent device. + * + * context: any context that permits to sleep. + */ +static void virtsnd_remove(struct virtio_device *vdev) +{ + struct virtio_snd *snd = vdev->priv; + + virtsnd_disable_event_vq(snd); + + if (snd->card) + snd_card_free(snd->card); + + vdev->config->del_vqs(vdev); + vdev->config->reset(vdev); + + kfree(snd->event_msgs); +} + +static const struct virtio_device_id id_table[] = { + { virtio_id_sound, virtio_dev_any_id }, + { 0 }, +}; + +static struct virtio_driver virtsnd_driver = { + .driver.name = kbuild_modname, + .driver.owner = this_module, + .id_table = id_table, + .validate = virtsnd_validate, + .probe = virtsnd_probe, + .remove = virtsnd_remove, +}; + +static int __init init(void) +{ + return register_virtio_driver(&virtsnd_driver); +} +module_init(init); + +static void __exit fini(void) +{ + unregister_virtio_driver(&virtsnd_driver); +} +module_exit(fini); + +module_device_table(virtio, id_table); +module_description("virtio sound card driver"); +module_license("gpl"); diff --git a/sound/virtio/virtio_card.h b/sound/virtio/virtio_card.h --- /dev/null +++ b/sound/virtio/virtio_card.h +/* spdx-license-identifier: gpl-2.0+ */ +/* + * virtio-snd: virtio sound device + * copyright (c) 2021 opensynergy gmbh + */ +#ifndef virtio_snd_card_h +#define virtio_snd_card_h + +#include <linux/slab.h> +#include <linux/virtio.h> +#include <sound/core.h> +#include <uapi/linux/virtio_snd.h> + +#define virtio_snd_card_driver "virtio-snd" +#define virtio_snd_card_name "virtio soundcard" + +/** + * struct virtio_snd_queue - virtqueue wrapper structure. + * @lock: used to synchronize access to a virtqueue. + * @vqueue: underlying virtqueue. + */ +struct virtio_snd_queue { + spinlock_t lock; + struct virtqueue *vqueue; +}; + +/** + * struct virtio_snd - virtio sound card device. + * @vdev: underlying virtio device. + * @queues: virtqueue wrappers. + * @card: alsa sound card. + * @event_msgs: device events. + */ +struct virtio_snd { + struct virtio_device *vdev; + struct virtio_snd_queue queues[virtio_snd_vq_max]; + struct snd_card *card; + struct virtio_snd_event *event_msgs; +}; + +static inline struct virtio_snd_queue * +virtsnd_control_queue(struct virtio_snd *snd) +{ + return &snd->queues[virtio_snd_vq_control]; +} + +static inline struct virtio_snd_queue * +virtsnd_event_queue(struct virtio_snd *snd) +{ + return &snd->queues[virtio_snd_vq_event]; +} + +static inline struct virtio_snd_queue * +virtsnd_tx_queue(struct virtio_snd *snd) +{ + return &snd->queues[virtio_snd_vq_tx]; +} + +static inline struct virtio_snd_queue * +virtsnd_rx_queue(struct virtio_snd *snd) +{ + return &snd->queues[virtio_snd_vq_rx]; +} + +#endif /* virtio_snd_card_h */
|
Audio
|
de3a9980d8c34b2479173e809afa820473db676a
|
anton yakovlev
|
include
|
uapi
|
linux
|
alsa: virtio: handling control messages
|
the control queue can be used by different parts of the driver to send commands to the device. control messages can be either synchronous or asynchronous. the lifetime of a message is controlled by a reference count.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
(featured) add virtio sound driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'c', 'makefile']
| 5
| 410
| 1
|
--- diff --git a/sound/virtio/makefile b/sound/virtio/makefile --- a/sound/virtio/makefile +++ b/sound/virtio/makefile - virtio_card.o + virtio_card.o \ + virtio_ctl_msg.o diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c --- a/sound/virtio/virtio_card.c +++ b/sound/virtio/virtio_card.c +u32 virtsnd_msg_timeout_ms = msec_per_sec; +module_param_named(msg_timeout_ms, virtsnd_msg_timeout_ms, uint, 0644); +module_parm_desc(msg_timeout_ms, "message completion timeout in milliseconds"); + + [virtio_snd_vq_control] = virtsnd_ctl_notify_cb, + [virtio_snd_vq_control] = "virtsnd-ctl", + if (!virtsnd_msg_timeout_ms) { + dev_err(&vdev->dev, "msg_timeout_ms value cannot be zero "); + return -einval; + } + + init_list_head(&snd->ctl_msgs); + virtsnd_ctl_msg_cancel_all(snd); diff --git a/sound/virtio/virtio_card.h b/sound/virtio/virtio_card.h --- a/sound/virtio/virtio_card.h +++ b/sound/virtio/virtio_card.h +#include "virtio_ctl_msg.h" + + * @ctl_msgs: pending control request list. + struct list_head ctl_msgs; +/* message completion timeout in milliseconds (module parameter). */ +extern u32 virtsnd_msg_timeout_ms; + diff --git a/sound/virtio/virtio_ctl_msg.c b/sound/virtio/virtio_ctl_msg.c --- /dev/null +++ b/sound/virtio/virtio_ctl_msg.c +// spdx-license-identifier: gpl-2.0+ +/* + * virtio-snd: virtio sound device + * copyright (c) 2021 opensynergy gmbh + */ +#include <linux/moduleparam.h> +#include <linux/virtio_config.h> + +#include "virtio_card.h" + +/** + * struct virtio_snd_msg - control message. + * @sg_request: scattergather list containing a device request (header). + * @sg_response: scattergather list containing a device response (status). + * @list: pending message list entry. + * @notify: request completed notification. + * @ref_count: reference count used to manage a message lifetime. + */ +struct virtio_snd_msg { + struct scatterlist sg_request; + struct scatterlist sg_response; + struct list_head list; + struct completion notify; + refcount_t ref_count; +}; + +/** + * virtsnd_ctl_msg_ref() - increment reference counter for the message. + * @msg: control message. + * + * context: any context. + */ +void virtsnd_ctl_msg_ref(struct virtio_snd_msg *msg) +{ + refcount_inc(&msg->ref_count); +} + +/** + * virtsnd_ctl_msg_unref() - decrement reference counter for the message. + * @msg: control message. + * + * the message will be freed when the ref_count value is 0. + * + * context: any context. + */ +void virtsnd_ctl_msg_unref(struct virtio_snd_msg *msg) +{ + if (refcount_dec_and_test(&msg->ref_count)) + kfree(msg); +} + +/** + * virtsnd_ctl_msg_request() - get a pointer to the request header. + * @msg: control message. + * + * context: any context. + */ +void *virtsnd_ctl_msg_request(struct virtio_snd_msg *msg) +{ + return sg_virt(&msg->sg_request); +} + +/** + * virtsnd_ctl_msg_request() - get a pointer to the response header. + * @msg: control message. + * + * context: any context. + */ +void *virtsnd_ctl_msg_response(struct virtio_snd_msg *msg) +{ + return sg_virt(&msg->sg_response); +} + +/** + * virtsnd_ctl_msg_alloc() - allocate and initialize a control message. + * @request_size: size of request header. + * @response_size: size of response header. + * @gfp: kernel flags for memory allocation. + * + * the message will be automatically freed when the ref_count value is 0. + * + * context: any context. may sleep if @gfp flags permit. + * return: allocated message on success, null on failure. + */ +struct virtio_snd_msg *virtsnd_ctl_msg_alloc(size_t request_size, + size_t response_size, gfp_t gfp) +{ + struct virtio_snd_msg *msg; + + if (!request_size || !response_size) + return null; + + msg = kzalloc(sizeof(*msg) + request_size + response_size, gfp); + if (!msg) + return null; + + sg_init_one(&msg->sg_request, (u8 *)msg + sizeof(*msg), request_size); + sg_init_one(&msg->sg_response, (u8 *)msg + sizeof(*msg) + request_size, + response_size); + + init_list_head(&msg->list); + init_completion(&msg->notify); + /* this reference is dropped in virtsnd_ctl_msg_complete(). */ + refcount_set(&msg->ref_count, 1); + + return msg; +} + +/** + * virtsnd_ctl_msg_send() - send a control message. + * @snd: virtio sound device. + * @msg: control message. + * @out_sgs: additional sg-list to attach to the request header (may be null). + * @in_sgs: additional sg-list to attach to the response header (may be null). + * @nowait: flag indicating whether to wait for completion. + * + * context: any context. takes and releases the control queue spinlock. + * may sleep if @nowait is false. + * return: 0 on success, -errno on failure. + */ +int virtsnd_ctl_msg_send(struct virtio_snd *snd, struct virtio_snd_msg *msg, + struct scatterlist *out_sgs, + struct scatterlist *in_sgs, bool nowait) +{ + struct virtio_device *vdev = snd->vdev; + struct virtio_snd_queue *queue = virtsnd_control_queue(snd); + unsigned int js = msecs_to_jiffies(virtsnd_msg_timeout_ms); + struct virtio_snd_hdr *request = virtsnd_ctl_msg_request(msg); + struct virtio_snd_hdr *response = virtsnd_ctl_msg_response(msg); + unsigned int nouts = 0; + unsigned int nins = 0; + struct scatterlist *psgs[4]; + bool notify = false; + unsigned long flags; + int rc; + + virtsnd_ctl_msg_ref(msg); + + /* set the default status in case the message was canceled. */ + response->code = cpu_to_le32(virtio_snd_s_io_err); + + psgs[nouts++] = &msg->sg_request; + if (out_sgs) + psgs[nouts++] = out_sgs; + + psgs[nouts + nins++] = &msg->sg_response; + if (in_sgs) + psgs[nouts + nins++] = in_sgs; + + spin_lock_irqsave(&queue->lock, flags); + rc = virtqueue_add_sgs(queue->vqueue, psgs, nouts, nins, msg, + gfp_atomic); + if (!rc) { + notify = virtqueue_kick_prepare(queue->vqueue); + + list_add_tail(&msg->list, &snd->ctl_msgs); + } + spin_unlock_irqrestore(&queue->lock, flags); + + if (rc) { + dev_err(&vdev->dev, "failed to send control message (0x%08x) ", + le32_to_cpu(request->code)); + + /* + * since in this case virtsnd_ctl_msg_complete() will not be + * called, it is necessary to decrement the reference count. + */ + virtsnd_ctl_msg_unref(msg); + + goto on_exit; + } + + if (notify) + virtqueue_notify(queue->vqueue); + + if (nowait) + goto on_exit; + + rc = wait_for_completion_interruptible_timeout(&msg->notify, js); + if (rc <= 0) { + if (!rc) { + dev_err(&vdev->dev, + "control message (0x%08x) timeout ", + le32_to_cpu(request->code)); + rc = -etimedout; + } + + goto on_exit; + } + + switch (le32_to_cpu(response->code)) { + case virtio_snd_s_ok: + rc = 0; + break; + case virtio_snd_s_not_supp: + rc = -eopnotsupp; + break; + case virtio_snd_s_io_err: + rc = -eio; + break; + default: + rc = -einval; + break; + } + +on_exit: + virtsnd_ctl_msg_unref(msg); + + return rc; +} + +/** + * virtsnd_ctl_msg_complete() - complete a control message. + * @msg: control message. + * + * context: any context. expects the control queue spinlock to be held by + * caller. + */ +void virtsnd_ctl_msg_complete(struct virtio_snd_msg *msg) +{ + list_del(&msg->list); + complete(&msg->notify); + + virtsnd_ctl_msg_unref(msg); +} + +/** + * virtsnd_ctl_msg_cancel_all() - cancel all pending control messages. + * @snd: virtio sound device. + * + * context: any context. + */ +void virtsnd_ctl_msg_cancel_all(struct virtio_snd *snd) +{ + struct virtio_snd_queue *queue = virtsnd_control_queue(snd); + unsigned long flags; + + spin_lock_irqsave(&queue->lock, flags); + while (!list_empty(&snd->ctl_msgs)) { + struct virtio_snd_msg *msg = + list_first_entry(&snd->ctl_msgs, struct virtio_snd_msg, + list); + + virtsnd_ctl_msg_complete(msg); + } + spin_unlock_irqrestore(&queue->lock, flags); +} + +/** + * virtsnd_ctl_query_info() - query the item configuration from the device. + * @snd: virtio sound device. + * @command: control request code (virtio_snd_r_xxx_info). + * @start_id: item start identifier. + * @count: item count to query. + * @size: item information size in bytes. + * @info: buffer for storing item information. + * + * context: any context that permits to sleep. + * return: 0 on success, -errno on failure. + */ +int virtsnd_ctl_query_info(struct virtio_snd *snd, int command, int start_id, + int count, size_t size, void *info) +{ + struct virtio_snd_msg *msg; + struct virtio_snd_query_info *query; + struct scatterlist sg; + + msg = virtsnd_ctl_msg_alloc(sizeof(*query), + sizeof(struct virtio_snd_hdr), gfp_kernel); + if (!msg) + return -enomem; + + query = virtsnd_ctl_msg_request(msg); + query->hdr.code = cpu_to_le32(command); + query->start_id = cpu_to_le32(start_id); + query->count = cpu_to_le32(count); + query->size = cpu_to_le32(size); + + sg_init_one(&sg, info, count * size); + + return virtsnd_ctl_msg_send(snd, msg, null, &sg, false); +} + +/** + * virtsnd_ctl_notify_cb() - process all completed control messages. + * @vqueue: underlying control virtqueue. + * + * this callback function is called upon a vring interrupt request from the + * device. + * + * context: interrupt context. takes and releases the control queue spinlock. + */ +void virtsnd_ctl_notify_cb(struct virtqueue *vqueue) +{ + struct virtio_snd *snd = vqueue->vdev->priv; + struct virtio_snd_queue *queue = virtsnd_control_queue(snd); + struct virtio_snd_msg *msg; + u32 length; + unsigned long flags; + + spin_lock_irqsave(&queue->lock, flags); + do { + virtqueue_disable_cb(vqueue); + while ((msg = virtqueue_get_buf(vqueue, &length))) + virtsnd_ctl_msg_complete(msg); + if (unlikely(virtqueue_is_broken(vqueue))) + break; + } while (!virtqueue_enable_cb(vqueue)); + spin_unlock_irqrestore(&queue->lock, flags); +} diff --git a/sound/virtio/virtio_ctl_msg.h b/sound/virtio/virtio_ctl_msg.h --- /dev/null +++ b/sound/virtio/virtio_ctl_msg.h +/* spdx-license-identifier: gpl-2.0+ */ +/* + * virtio-snd: virtio sound device + * copyright (c) 2021 opensynergy gmbh + */ +#ifndef virtio_snd_msg_h +#define virtio_snd_msg_h + +#include <linux/atomic.h> +#include <linux/virtio.h> + +struct virtio_snd; +struct virtio_snd_msg; + +void virtsnd_ctl_msg_ref(struct virtio_snd_msg *msg); + +void virtsnd_ctl_msg_unref(struct virtio_snd_msg *msg); + +void *virtsnd_ctl_msg_request(struct virtio_snd_msg *msg); + +void *virtsnd_ctl_msg_response(struct virtio_snd_msg *msg); + +struct virtio_snd_msg *virtsnd_ctl_msg_alloc(size_t request_size, + size_t response_size, gfp_t gfp); + +int virtsnd_ctl_msg_send(struct virtio_snd *snd, struct virtio_snd_msg *msg, + struct scatterlist *out_sgs, + struct scatterlist *in_sgs, bool nowait); + +/** + * virtsnd_ctl_msg_send_sync() - simplified sending of synchronous message. + * @snd: virtio sound device. + * @msg: control message. + * + * after returning from this function, the message will be deleted. if message + * content is still needed, the caller must additionally to + * virtsnd_ctl_msg_ref/unref() it. + * + * the msg_timeout_ms module parameter defines the message completion timeout. + * if the message is not completed within this time, the function will return an + * error. + * + * context: any context that permits to sleep. + * return: 0 on success, -errno on failure. + * + * the return value is a message status code (virtio_snd_s_xxx) converted to an + * appropriate -errno value. + */ +static inline int virtsnd_ctl_msg_send_sync(struct virtio_snd *snd, + struct virtio_snd_msg *msg) +{ + return virtsnd_ctl_msg_send(snd, msg, null, null, false); +} + +/** + * virtsnd_ctl_msg_send_async() - simplified sending of asynchronous message. + * @snd: virtio sound device. + * @msg: control message. + * + * context: any context. + * return: 0 on success, -errno on failure. + */ +static inline int virtsnd_ctl_msg_send_async(struct virtio_snd *snd, + struct virtio_snd_msg *msg) +{ + return virtsnd_ctl_msg_send(snd, msg, null, null, true); +} + +void virtsnd_ctl_msg_cancel_all(struct virtio_snd *snd); + +void virtsnd_ctl_msg_complete(struct virtio_snd_msg *msg); + +int virtsnd_ctl_query_info(struct virtio_snd *snd, int command, int start_id, + int count, size_t size, void *info); + +void virtsnd_ctl_notify_cb(struct virtqueue *vqueue); + +#endif /* virtio_snd_msg_h */
|
Audio
|
9d45e514da88ff74fc24ffb34e7d6eb92576440b
|
anton yakovlev
|
sound
|
virtio
| |
alsa: virtio: build pcm devices and substream hardware descriptors
|
like the hda specification, the virtio sound device specification links pcm substreams, jacks and pcm channel maps into functional groups. for each discovered group, a pcm device is created, the number of which coincides with the group number.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
(featured) add virtio sound driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'c', 'makefile']
| 5
| 581
| 1
|
--- diff --git a/sound/virtio/makefile b/sound/virtio/makefile --- a/sound/virtio/makefile +++ b/sound/virtio/makefile - virtio_ctl_msg.o + virtio_ctl_msg.o \ + virtio_pcm.o diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c --- a/sound/virtio/virtio_card.c +++ b/sound/virtio/virtio_card.c + rc = virtsnd_pcm_parse_cfg(snd); + if (rc) + return rc; + + if (snd->nsubstreams) { + rc = virtsnd_pcm_build_devs(snd); + if (rc) + return rc; + } + + if (virtsnd_pcm_validate(vdev)) + return -einval; + + init_list_head(&snd->pcm_list); + unsigned int i; + for (i = 0; snd->substreams && i < snd->nsubstreams; ++i) + cancel_work_sync(&snd->substreams[i].elapsed_period); + diff --git a/sound/virtio/virtio_card.h b/sound/virtio/virtio_card.h --- a/sound/virtio/virtio_card.h +++ b/sound/virtio/virtio_card.h +#include "virtio_pcm.h" +#define virtio_snd_pcm_name "virtio pcm" + +struct virtio_pcm_substream; + * @pcm_list: virtio pcm device list. + * @substreams: virtio pcm substreams. + * @nsubstreams: number of pcm substreams. + struct list_head pcm_list; + struct virtio_pcm_substream *substreams; + u32 nsubstreams; diff --git a/sound/virtio/virtio_pcm.c b/sound/virtio/virtio_pcm.c --- /dev/null +++ b/sound/virtio/virtio_pcm.c +// spdx-license-identifier: gpl-2.0+ +/* + * virtio-snd: virtio sound device + * copyright (c) 2021 opensynergy gmbh + */ +#include <linux/moduleparam.h> +#include <linux/virtio_config.h> + +#include "virtio_card.h" + +static u32 pcm_buffer_ms = 160; +module_param(pcm_buffer_ms, uint, 0644); +module_parm_desc(pcm_buffer_ms, "pcm substream buffer time in milliseconds"); + +static u32 pcm_periods_min = 2; +module_param(pcm_periods_min, uint, 0644); +module_parm_desc(pcm_periods_min, "minimum number of pcm periods"); + +static u32 pcm_periods_max = 16; +module_param(pcm_periods_max, uint, 0644); +module_parm_desc(pcm_periods_max, "maximum number of pcm periods"); + +static u32 pcm_period_ms_min = 10; +module_param(pcm_period_ms_min, uint, 0644); +module_parm_desc(pcm_period_ms_min, "minimum pcm period time in milliseconds"); + +static u32 pcm_period_ms_max = 80; +module_param(pcm_period_ms_max, uint, 0644); +module_parm_desc(pcm_period_ms_max, "maximum pcm period time in milliseconds"); + +/* map for converting virtio format to alsa format. */ +static const snd_pcm_format_t g_v2a_format_map[] = { + [virtio_snd_pcm_fmt_ima_adpcm] = sndrv_pcm_format_ima_adpcm, + [virtio_snd_pcm_fmt_mu_law] = sndrv_pcm_format_mu_law, + [virtio_snd_pcm_fmt_a_law] = sndrv_pcm_format_a_law, + [virtio_snd_pcm_fmt_s8] = sndrv_pcm_format_s8, + [virtio_snd_pcm_fmt_u8] = sndrv_pcm_format_u8, + [virtio_snd_pcm_fmt_s16] = sndrv_pcm_format_s16_le, + [virtio_snd_pcm_fmt_u16] = sndrv_pcm_format_u16_le, + [virtio_snd_pcm_fmt_s18_3] = sndrv_pcm_format_s18_3le, + [virtio_snd_pcm_fmt_u18_3] = sndrv_pcm_format_u18_3le, + [virtio_snd_pcm_fmt_s20_3] = sndrv_pcm_format_s20_3le, + [virtio_snd_pcm_fmt_u20_3] = sndrv_pcm_format_u20_3le, + [virtio_snd_pcm_fmt_s24_3] = sndrv_pcm_format_s24_3le, + [virtio_snd_pcm_fmt_u24_3] = sndrv_pcm_format_u24_3le, + [virtio_snd_pcm_fmt_s20] = sndrv_pcm_format_s20_le, + [virtio_snd_pcm_fmt_u20] = sndrv_pcm_format_u20_le, + [virtio_snd_pcm_fmt_s24] = sndrv_pcm_format_s24_le, + [virtio_snd_pcm_fmt_u24] = sndrv_pcm_format_u24_le, + [virtio_snd_pcm_fmt_s32] = sndrv_pcm_format_s32_le, + [virtio_snd_pcm_fmt_u32] = sndrv_pcm_format_u32_le, + [virtio_snd_pcm_fmt_float] = sndrv_pcm_format_float_le, + [virtio_snd_pcm_fmt_float64] = sndrv_pcm_format_float64_le, + [virtio_snd_pcm_fmt_dsd_u8] = sndrv_pcm_format_dsd_u8, + [virtio_snd_pcm_fmt_dsd_u16] = sndrv_pcm_format_dsd_u16_le, + [virtio_snd_pcm_fmt_dsd_u32] = sndrv_pcm_format_dsd_u32_le, + [virtio_snd_pcm_fmt_iec958_subframe] = + sndrv_pcm_format_iec958_subframe_le +}; + +/* map for converting virtio frame rate to alsa frame rate. */ +struct virtsnd_v2a_rate { + unsigned int alsa_bit; + unsigned int rate; +}; + +static const struct virtsnd_v2a_rate g_v2a_rate_map[] = { + [virtio_snd_pcm_rate_5512] = { sndrv_pcm_rate_5512, 5512 }, + [virtio_snd_pcm_rate_8000] = { sndrv_pcm_rate_8000, 8000 }, + [virtio_snd_pcm_rate_11025] = { sndrv_pcm_rate_11025, 11025 }, + [virtio_snd_pcm_rate_16000] = { sndrv_pcm_rate_16000, 16000 }, + [virtio_snd_pcm_rate_22050] = { sndrv_pcm_rate_22050, 22050 }, + [virtio_snd_pcm_rate_32000] = { sndrv_pcm_rate_32000, 32000 }, + [virtio_snd_pcm_rate_44100] = { sndrv_pcm_rate_44100, 44100 }, + [virtio_snd_pcm_rate_48000] = { sndrv_pcm_rate_48000, 48000 }, + [virtio_snd_pcm_rate_64000] = { sndrv_pcm_rate_64000, 64000 }, + [virtio_snd_pcm_rate_88200] = { sndrv_pcm_rate_88200, 88200 }, + [virtio_snd_pcm_rate_96000] = { sndrv_pcm_rate_96000, 96000 }, + [virtio_snd_pcm_rate_176400] = { sndrv_pcm_rate_176400, 176400 }, + [virtio_snd_pcm_rate_192000] = { sndrv_pcm_rate_192000, 192000 } +}; + +/** + * virtsnd_pcm_build_hw() - parse substream config and build hw descriptor. + * @vss: virtio substream. + * @info: virtio substream information entry. + * + * context: any context. + * return: 0 on success, -einval if configuration is invalid. + */ +static int virtsnd_pcm_build_hw(struct virtio_pcm_substream *vss, + struct virtio_snd_pcm_info *info) +{ + struct virtio_device *vdev = vss->snd->vdev; + unsigned int i; + u64 values; + size_t sample_max = 0; + size_t sample_min = 0; + + vss->features = le32_to_cpu(info->features); + + /* + * todo: set sndrv_pcm_info_{batch,block_transfer} if device supports + * only message-based transport. + */ + vss->hw.info = + sndrv_pcm_info_mmap | + sndrv_pcm_info_mmap_valid | + sndrv_pcm_info_batch | + sndrv_pcm_info_block_transfer | + sndrv_pcm_info_interleaved | + sndrv_pcm_info_pause; + + if (!info->channels_min || info->channels_min > info->channels_max) { + dev_err(&vdev->dev, + "sid %u: invalid channel range [%u %u] ", + vss->sid, info->channels_min, info->channels_max); + return -einval; + } + + vss->hw.channels_min = info->channels_min; + vss->hw.channels_max = info->channels_max; + + values = le64_to_cpu(info->formats); + + vss->hw.formats = 0; + + for (i = 0; i < array_size(g_v2a_format_map); ++i) + if (values & (1ull << i)) { + snd_pcm_format_t alsa_fmt = g_v2a_format_map[i]; + int bytes = snd_pcm_format_physical_width(alsa_fmt) / 8; + + if (!sample_min || sample_min > bytes) + sample_min = bytes; + + if (sample_max < bytes) + sample_max = bytes; + + vss->hw.formats |= pcm_format_to_bits(alsa_fmt); + } + + if (!vss->hw.formats) { + dev_err(&vdev->dev, + "sid %u: no supported pcm sample formats found ", + vss->sid); + return -einval; + } + + values = le64_to_cpu(info->rates); + + vss->hw.rates = 0; + + for (i = 0; i < array_size(g_v2a_rate_map); ++i) + if (values & (1ull << i)) { + if (!vss->hw.rate_min || + vss->hw.rate_min > g_v2a_rate_map[i].rate) + vss->hw.rate_min = g_v2a_rate_map[i].rate; + + if (vss->hw.rate_max < g_v2a_rate_map[i].rate) + vss->hw.rate_max = g_v2a_rate_map[i].rate; + + vss->hw.rates |= g_v2a_rate_map[i].alsa_bit; + } + + if (!vss->hw.rates) { + dev_err(&vdev->dev, + "sid %u: no supported pcm frame rates found ", + vss->sid); + return -einval; + } + + vss->hw.periods_min = pcm_periods_min; + vss->hw.periods_max = pcm_periods_max; + + /* + * we must ensure that there is enough space in the buffer to store + * pcm_buffer_ms ms for the combination (cmax, smax, rmax), where: + * cmax = maximum supported number of channels, + * smax = maximum supported sample size in bytes, + * rmax = maximum supported frame rate. + */ + vss->hw.buffer_bytes_max = + page_align(sample_max * vss->hw.channels_max * pcm_buffer_ms * + (vss->hw.rate_max / msec_per_sec)); + + /* + * we must ensure that the minimum period size is enough to store + * pcm_period_ms_min ms for the combination (cmin, smin, rmin), where: + * cmin = minimum supported number of channels, + * smin = minimum supported sample size in bytes, + * rmin = minimum supported frame rate. + */ + vss->hw.period_bytes_min = + sample_min * vss->hw.channels_min * pcm_period_ms_min * + (vss->hw.rate_min / msec_per_sec); + + /* + * we must ensure that the maximum period size is enough to store + * pcm_period_ms_max ms for the combination (cmax, smax, rmax). + */ + vss->hw.period_bytes_max = + sample_max * vss->hw.channels_max * pcm_period_ms_max * + (vss->hw.rate_max / msec_per_sec); + + return 0; +} + +/** + * virtsnd_pcm_find() - find the pcm device for the specified node id. + * @snd: virtio sound device. + * @nid: function node id. + * + * context: any context. + * return: a pointer to the pcm device or err_ptr(-enoent). + */ +struct virtio_pcm *virtsnd_pcm_find(struct virtio_snd *snd, u32 nid) +{ + struct virtio_pcm *vpcm; + + list_for_each_entry(vpcm, &snd->pcm_list, list) + if (vpcm->nid == nid) + return vpcm; + + return err_ptr(-enoent); +} + +/** + * virtsnd_pcm_find_or_create() - find or create the pcm device for the + * specified node id. + * @snd: virtio sound device. + * @nid: function node id. + * + * context: any context that permits to sleep. + * return: a pointer to the pcm device or err_ptr(-errno). + */ +struct virtio_pcm *virtsnd_pcm_find_or_create(struct virtio_snd *snd, u32 nid) +{ + struct virtio_device *vdev = snd->vdev; + struct virtio_pcm *vpcm; + + vpcm = virtsnd_pcm_find(snd, nid); + if (!is_err(vpcm)) + return vpcm; + + vpcm = devm_kzalloc(&vdev->dev, sizeof(*vpcm), gfp_kernel); + if (!vpcm) + return err_ptr(-enomem); + + vpcm->nid = nid; + list_add_tail(&vpcm->list, &snd->pcm_list); + + return vpcm; +} + +/** + * virtsnd_pcm_validate() - validate if the device can be started. + * @vdev: virtio parent device. + * + * context: any context. + * return: 0 on success, -einval on failure. + */ +int virtsnd_pcm_validate(struct virtio_device *vdev) +{ + if (pcm_periods_min < 2 || pcm_periods_min > pcm_periods_max) { + dev_err(&vdev->dev, + "invalid range [%u %u] of the number of pcm periods ", + pcm_periods_min, pcm_periods_max); + return -einval; + } + + if (!pcm_period_ms_min || pcm_period_ms_min > pcm_period_ms_max) { + dev_err(&vdev->dev, + "invalid range [%u %u] of the size of the pcm period ", + pcm_period_ms_min, pcm_period_ms_max); + return -einval; + } + + if (pcm_buffer_ms < pcm_periods_min * pcm_period_ms_min) { + dev_err(&vdev->dev, + "pcm_buffer_ms(=%u) value cannot be < %u ms ", + pcm_buffer_ms, pcm_periods_min * pcm_period_ms_min); + return -einval; + } + + if (pcm_period_ms_max > pcm_buffer_ms / 2) { + dev_err(&vdev->dev, + "pcm_period_ms_max(=%u) value cannot be > %u ms ", + pcm_period_ms_max, pcm_buffer_ms / 2); + return -einval; + } + + return 0; +} + +/** + * virtsnd_pcm_period_elapsed() - kernel work function to handle the elapsed + * period state. + * @work: elapsed period work. + * + * the main purpose of this function is to call snd_pcm_period_elapsed() in + * a process context, not in an interrupt context. this is necessary because pcm + * devices operate in non-atomic mode. + * + * context: process context. + */ +static void virtsnd_pcm_period_elapsed(struct work_struct *work) +{ + struct virtio_pcm_substream *vss = + container_of(work, struct virtio_pcm_substream, elapsed_period); + + snd_pcm_period_elapsed(vss->substream); +} + +/** + * virtsnd_pcm_parse_cfg() - parse the stream configuration. + * @snd: virtio sound device. + * + * this function is called during initial device initialization. + * + * context: any context that permits to sleep. + * return: 0 on success, -errno on failure. + */ +int virtsnd_pcm_parse_cfg(struct virtio_snd *snd) +{ + struct virtio_device *vdev = snd->vdev; + struct virtio_snd_pcm_info *info; + u32 i; + int rc; + + virtio_cread_le(vdev, struct virtio_snd_config, streams, + &snd->nsubstreams); + if (!snd->nsubstreams) + return 0; + + snd->substreams = devm_kcalloc(&vdev->dev, snd->nsubstreams, + sizeof(*snd->substreams), gfp_kernel); + if (!snd->substreams) + return -enomem; + + info = kcalloc(snd->nsubstreams, sizeof(*info), gfp_kernel); + if (!info) + return -enomem; + + rc = virtsnd_ctl_query_info(snd, virtio_snd_r_pcm_info, 0, + snd->nsubstreams, sizeof(*info), info); + if (rc) + goto on_exit; + + for (i = 0; i < snd->nsubstreams; ++i) { + struct virtio_pcm_substream *vss = &snd->substreams[i]; + struct virtio_pcm *vpcm; + + vss->snd = snd; + vss->sid = i; + init_work(&vss->elapsed_period, virtsnd_pcm_period_elapsed); + + rc = virtsnd_pcm_build_hw(vss, &info[i]); + if (rc) + goto on_exit; + + vss->nid = le32_to_cpu(info[i].hdr.hda_fn_nid); + + vpcm = virtsnd_pcm_find_or_create(snd, vss->nid); + if (is_err(vpcm)) { + rc = ptr_err(vpcm); + goto on_exit; + } + + switch (info[i].direction) { + case virtio_snd_d_output: + vss->direction = sndrv_pcm_stream_playback; + break; + case virtio_snd_d_input: + vss->direction = sndrv_pcm_stream_capture; + break; + default: + dev_err(&vdev->dev, "sid %u: unknown direction (%u) ", + vss->sid, info[i].direction); + rc = -einval; + goto on_exit; + } + + vpcm->streams[vss->direction].nsubstreams++; + } + +on_exit: + kfree(info); + + return rc; +} + +/** + * virtsnd_pcm_build_devs() - build alsa pcm devices. + * @snd: virtio sound device. + * + * context: any context that permits to sleep. + * return: 0 on success, -errno on failure. + */ +int virtsnd_pcm_build_devs(struct virtio_snd *snd) +{ + struct virtio_device *vdev = snd->vdev; + struct virtio_pcm *vpcm; + u32 i; + int rc; + + list_for_each_entry(vpcm, &snd->pcm_list, list) { + unsigned int npbs = + vpcm->streams[sndrv_pcm_stream_playback].nsubstreams; + unsigned int ncps = + vpcm->streams[sndrv_pcm_stream_capture].nsubstreams; + + if (!npbs && !ncps) + continue; + + rc = snd_pcm_new(snd->card, virtio_snd_card_driver, vpcm->nid, + npbs, ncps, &vpcm->pcm); + if (rc) { + dev_err(&vdev->dev, "snd_pcm_new[%u] failed: %d ", + vpcm->nid, rc); + return rc; + } + + vpcm->pcm->info_flags = 0; + vpcm->pcm->dev_class = sndrv_pcm_class_generic; + vpcm->pcm->dev_subclass = sndrv_pcm_subclass_generic_mix; + snprintf(vpcm->pcm->name, sizeof(vpcm->pcm->name), + virtio_snd_pcm_name " %u", vpcm->pcm->device); + vpcm->pcm->private_data = vpcm; + vpcm->pcm->nonatomic = true; + + for (i = 0; i < array_size(vpcm->streams); ++i) { + struct virtio_pcm_stream *stream = &vpcm->streams[i]; + + if (!stream->nsubstreams) + continue; + + stream->substreams = + devm_kcalloc(&vdev->dev, stream->nsubstreams, + sizeof(*stream->substreams), + gfp_kernel); + if (!stream->substreams) + return -enomem; + + stream->nsubstreams = 0; + } + } + + for (i = 0; i < snd->nsubstreams; ++i) { + struct virtio_pcm_stream *vs; + struct virtio_pcm_substream *vss = &snd->substreams[i]; + + vpcm = virtsnd_pcm_find(snd, vss->nid); + if (is_err(vpcm)) + return ptr_err(vpcm); + + vs = &vpcm->streams[vss->direction]; + vs->substreams[vs->nsubstreams++] = vss; + } + + list_for_each_entry(vpcm, &snd->pcm_list, list) { + for (i = 0; i < array_size(vpcm->streams); ++i) { + struct virtio_pcm_stream *vs = &vpcm->streams[i]; + struct snd_pcm_str *ks = &vpcm->pcm->streams[i]; + struct snd_pcm_substream *kss; + + if (!vs->nsubstreams) + continue; + + for (kss = ks->substream; kss; kss = kss->next) + vs->substreams[kss->number]->substream = kss; + } + + snd_pcm_set_managed_buffer_all(vpcm->pcm, + sndrv_dma_type_vmalloc, null, + 0, 0); + } + + return 0; +} diff --git a/sound/virtio/virtio_pcm.h b/sound/virtio/virtio_pcm.h --- /dev/null +++ b/sound/virtio/virtio_pcm.h +/* spdx-license-identifier: gpl-2.0+ */ +/* + * virtio-snd: virtio sound device + * copyright (c) 2021 opensynergy gmbh + */ +#ifndef virtio_snd_pcm_h +#define virtio_snd_pcm_h + +#include <linux/atomic.h> +#include <linux/virtio_config.h> +#include <sound/pcm.h> + +struct virtio_pcm; +struct virtio_pcm_msg; + +/** + * struct virtio_pcm_substream - virtio pcm substream. + * @snd: virtio sound device. + * @nid: function group node identifier. + * @sid: stream identifier. + * @direction: stream data flow direction (sndrv_pcm_stream_xxx). + * @features: stream virtio feature bit map (1 << virtio_snd_pcm_f_xxx). + * @substream: kernel alsa substream. + * @hw: kernel alsa substream hardware descriptor. + * @elapsed_period: kernel work to handle the elapsed period state. + */ +struct virtio_pcm_substream { + struct virtio_snd *snd; + u32 nid; + u32 sid; + u32 direction; + u32 features; + struct snd_pcm_substream *substream; + struct snd_pcm_hardware hw; + struct work_struct elapsed_period; +}; + +/** + * struct virtio_pcm_stream - virtio pcm stream. + * @substreams: virtio substreams belonging to the stream. + * @nsubstreams: number of substreams. + */ +struct virtio_pcm_stream { + struct virtio_pcm_substream **substreams; + u32 nsubstreams; +}; + +/** + * struct virtio_pcm - virtio pcm device. + * @list: virtio pcm list entry. + * @nid: function group node identifier. + * @pcm: kernel pcm device. + * @streams: virtio pcm streams (playback and capture). + */ +struct virtio_pcm { + struct list_head list; + u32 nid; + struct snd_pcm *pcm; + struct virtio_pcm_stream streams[sndrv_pcm_stream_last + 1]; +}; + +int virtsnd_pcm_validate(struct virtio_device *vdev); + +int virtsnd_pcm_parse_cfg(struct virtio_snd *snd); + +int virtsnd_pcm_build_devs(struct virtio_snd *snd); + +struct virtio_pcm *virtsnd_pcm_find(struct virtio_snd *snd, u32 nid); + +struct virtio_pcm *virtsnd_pcm_find_or_create(struct virtio_snd *snd, u32 nid); + +#endif /* virtio_snd_pcm_h */
|
Audio
|
29b96bf50ba958eb5f097cdc3fbd4c1acf9547a2
|
anton yakovlev
|
sound
|
virtio
| |
alsa: virtio: handling control and i/o messages for the pcm device
|
the driver implements a message-based transport for i/o substream operations. before the start of the substream, the hardware buffer is sliced into i/o messages, the number of which is equal to the current number of periods. the size of each message is equal to the current size of one period.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
(featured) add virtio sound driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'c', 'makefile']
| 6
| 515
| 5
|
--- diff --git a/sound/virtio/makefile b/sound/virtio/makefile --- a/sound/virtio/makefile +++ b/sound/virtio/makefile - virtio_pcm.o + virtio_pcm.o \ + virtio_pcm_msg.o diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c --- a/sound/virtio/virtio_card.c +++ b/sound/virtio/virtio_card.c + switch (le32_to_cpu(event->hdr.code)) { + case virtio_snd_evt_pcm_period_elapsed: + case virtio_snd_evt_pcm_xrun: + virtsnd_pcm_event(snd, event); + break; + } - [virtio_snd_vq_event] = virtsnd_event_notify_cb + [virtio_snd_vq_event] = virtsnd_event_notify_cb, + [virtio_snd_vq_tx] = virtsnd_pcm_tx_notify_cb, + [virtio_snd_vq_rx] = virtsnd_pcm_rx_notify_cb - [virtio_snd_vq_event] = "virtsnd-event" + [virtio_snd_vq_event] = "virtsnd-event", + [virtio_snd_vq_tx] = "virtsnd-tx", + [virtio_snd_vq_rx] = "virtsnd-rx" - for (i = 0; snd->substreams && i < snd->nsubstreams; ++i) - cancel_work_sync(&snd->substreams[i].elapsed_period); + for (i = 0; snd->substreams && i < snd->nsubstreams; ++i) { + struct virtio_pcm_substream *vss = &snd->substreams[i]; + + cancel_work_sync(&vss->elapsed_period); + virtsnd_pcm_msg_free(vss); + } diff --git a/sound/virtio/virtio_card.h b/sound/virtio/virtio_card.h --- a/sound/virtio/virtio_card.h +++ b/sound/virtio/virtio_card.h +static inline struct virtio_snd_queue * +virtsnd_pcm_queue(struct virtio_pcm_substream *vss) +{ + if (vss->direction == sndrv_pcm_stream_playback) + return virtsnd_tx_queue(vss->snd); + else + return virtsnd_rx_queue(vss->snd); +} + diff --git a/sound/virtio/virtio_pcm.c b/sound/virtio/virtio_pcm.c --- a/sound/virtio/virtio_pcm.c +++ b/sound/virtio/virtio_pcm.c + init_waitqueue_head(&vss->msg_empty); + spin_lock_init(&vss->lock); + +/** + * virtsnd_pcm_event() - handle the pcm device event notification. + * @snd: virtio sound device. + * @event: virtio sound event. + * + * context: interrupt context. + */ +void virtsnd_pcm_event(struct virtio_snd *snd, struct virtio_snd_event *event) +{ + struct virtio_pcm_substream *vss; + u32 sid = le32_to_cpu(event->data); + + if (sid >= snd->nsubstreams) + return; + + vss = &snd->substreams[sid]; + + switch (le32_to_cpu(event->hdr.code)) { + case virtio_snd_evt_pcm_period_elapsed: + /* todo: deal with shmem elapsed period */ + break; + case virtio_snd_evt_pcm_xrun: + spin_lock(&vss->lock); + if (vss->xfer_enabled) + vss->xfer_xrun = true; + spin_unlock(&vss->lock); + break; + } +} diff --git a/sound/virtio/virtio_pcm.h b/sound/virtio/virtio_pcm.h --- a/sound/virtio/virtio_pcm.h +++ b/sound/virtio/virtio_pcm.h + * @lock: spinlock that protects fields shared by interrupt handlers and + * substream operators. + * @buffer_bytes: current buffer size in bytes. + * @hw_ptr: substream hardware pointer value in bytes [0 ... buffer_bytes). + * @xfer_enabled: data transfer state (0 - off, 1 - on). + * @xfer_xrun: data underflow/overflow state (0 - no xrun, 1 - xrun). + * @msgs: allocated i/o messages. + * @nmsgs: number of allocated i/o messages. + * @msg_last_enqueued: index of the last i/o message added to the virtqueue. + * @msg_count: number of pending i/o messages in the virtqueue. + * @msg_empty: notify when msg_count is zero. + spinlock_t lock; + size_t buffer_bytes; + size_t hw_ptr; + bool xfer_enabled; + bool xfer_xrun; + struct virtio_pcm_msg **msgs; + unsigned int nmsgs; + int msg_last_enqueued; + unsigned int msg_count; + wait_queue_head_t msg_empty; +void virtsnd_pcm_event(struct virtio_snd *snd, struct virtio_snd_event *event); + +void virtsnd_pcm_tx_notify_cb(struct virtqueue *vqueue); + +void virtsnd_pcm_rx_notify_cb(struct virtqueue *vqueue); + +struct virtio_snd_msg * +virtsnd_pcm_ctl_msg_alloc(struct virtio_pcm_substream *vss, + unsigned int command, gfp_t gfp); + +int virtsnd_pcm_msg_alloc(struct virtio_pcm_substream *vss, + unsigned int periods, unsigned int period_bytes); + +void virtsnd_pcm_msg_free(struct virtio_pcm_substream *vss); + +int virtsnd_pcm_msg_send(struct virtio_pcm_substream *vss); + +unsigned int virtsnd_pcm_msg_pending_num(struct virtio_pcm_substream *vss); + diff --git a/sound/virtio/virtio_pcm_msg.c b/sound/virtio/virtio_pcm_msg.c --- /dev/null +++ b/sound/virtio/virtio_pcm_msg.c +// spdx-license-identifier: gpl-2.0+ +/* + * virtio-snd: virtio sound device + * copyright (c) 2021 opensynergy gmbh + */ +#include <sound/pcm_params.h> + +#include "virtio_card.h" + +/** + * struct virtio_pcm_msg - virtio i/o message. + * @substream: virtio pcm substream. + * @xfer: request header payload. + * @status: response header payload. + * @length: data length in bytes. + * @sgs: payload scatter-gather table. + */ +struct virtio_pcm_msg { + struct virtio_pcm_substream *substream; + struct virtio_snd_pcm_xfer xfer; + struct virtio_snd_pcm_status status; + size_t length; + struct scatterlist sgs[0]; +}; + +/** + * enum pcm_msg_sg_index - index values for the virtio_pcm_msg->sgs field in + * an i/o message. + * @pcm_msg_sg_xfer: element containing a virtio_snd_pcm_xfer structure. + * @pcm_msg_sg_status: element containing a virtio_snd_pcm_status structure. + * @pcm_msg_sg_data: the first element containing a data buffer. + */ +enum pcm_msg_sg_index { + pcm_msg_sg_xfer = 0, + pcm_msg_sg_status, + pcm_msg_sg_data +}; + +/** + * virtsnd_pcm_sg_num() - count the number of sg-elements required to represent + * vmalloc'ed buffer. + * @data: pointer to vmalloc'ed buffer. + * @length: buffer size. + * + * context: any context. + * return: number of physically contiguous parts in the @data. + */ +static int virtsnd_pcm_sg_num(u8 *data, unsigned int length) +{ + phys_addr_t sg_address; + unsigned int sg_length; + int num = 0; + + while (length) { + struct page *pg = vmalloc_to_page(data); + phys_addr_t pg_address = page_to_phys(pg); + size_t pg_length; + + pg_length = page_size - offset_in_page(data); + if (pg_length > length) + pg_length = length; + + if (!num || sg_address + sg_length != pg_address) { + sg_address = pg_address; + sg_length = pg_length; + num++; + } else { + sg_length += pg_length; + } + + data += pg_length; + length -= pg_length; + } + + return num; +} + +/** + * virtsnd_pcm_sg_from() - build sg-list from vmalloc'ed buffer. + * @sgs: preallocated sg-list to populate. + * @nsgs: the maximum number of elements in the @sgs. + * @data: pointer to vmalloc'ed buffer. + * @length: buffer size. + * + * splits the buffer into physically contiguous parts and makes an sg-list of + * such parts. + * + * context: any context. + */ +static void virtsnd_pcm_sg_from(struct scatterlist *sgs, int nsgs, u8 *data, + unsigned int length) +{ + int idx = -1; + + while (length) { + struct page *pg = vmalloc_to_page(data); + size_t pg_length; + + pg_length = page_size - offset_in_page(data); + if (pg_length > length) + pg_length = length; + + if (idx == -1 || + sg_phys(&sgs[idx]) + sgs[idx].length != page_to_phys(pg)) { + if (idx + 1 == nsgs) + break; + sg_set_page(&sgs[++idx], pg, pg_length, + offset_in_page(data)); + } else { + sgs[idx].length += pg_length; + } + + data += pg_length; + length -= pg_length; + } + + sg_mark_end(&sgs[idx]); +} + +/** + * virtsnd_pcm_msg_alloc() - allocate i/o messages. + * @vss: virtio pcm substream. + * @periods: current number of periods. + * @period_bytes: current period size in bytes. + * + * the function slices the buffer into @periods parts (each with the size of + * @period_bytes), and creates @periods corresponding i/o messages. + * + * context: any context that permits to sleep. + * return: 0 on success, -enomem on failure. + */ +int virtsnd_pcm_msg_alloc(struct virtio_pcm_substream *vss, + unsigned int periods, unsigned int period_bytes) +{ + struct snd_pcm_runtime *runtime = vss->substream->runtime; + unsigned int i; + + vss->msgs = kcalloc(periods, sizeof(*vss->msgs), gfp_kernel); + if (!vss->msgs) + return -enomem; + + vss->nmsgs = periods; + + for (i = 0; i < periods; ++i) { + u8 *data = runtime->dma_area + period_bytes * i; + int sg_num = virtsnd_pcm_sg_num(data, period_bytes); + struct virtio_pcm_msg *msg; + + msg = kzalloc(sizeof(*msg) + sizeof(*msg->sgs) * (sg_num + 2), + gfp_kernel); + if (!msg) + return -enomem; + + msg->substream = vss; + sg_init_one(&msg->sgs[pcm_msg_sg_xfer], &msg->xfer, + sizeof(msg->xfer)); + sg_init_one(&msg->sgs[pcm_msg_sg_status], &msg->status, + sizeof(msg->status)); + msg->length = period_bytes; + virtsnd_pcm_sg_from(&msg->sgs[pcm_msg_sg_data], sg_num, data, + period_bytes); + + vss->msgs[i] = msg; + } + + return 0; +} + +/** + * virtsnd_pcm_msg_free() - free all allocated i/o messages. + * @vss: virtio pcm substream. + * + * context: any context. + */ +void virtsnd_pcm_msg_free(struct virtio_pcm_substream *vss) +{ + unsigned int i; + + for (i = 0; vss->msgs && i < vss->nmsgs; ++i) + kfree(vss->msgs[i]); + kfree(vss->msgs); + + vss->msgs = null; + vss->nmsgs = 0; +} + +/** + * virtsnd_pcm_msg_send() - send asynchronous i/o messages. + * @vss: virtio pcm substream. + * + * all messages are organized in an ordered circular list. each time the + * function is called, all currently non-enqueued messages are added to the + * virtqueue. for this, the function keeps track of two values: + * + * msg_last_enqueued = index of the last enqueued message, + * msg_count = # of pending messages in the virtqueue. + * + * context: any context. expects the tx/rx queue and the virtio substream + * spinlocks to be held by caller. + * return: 0 on success, -errno on failure. + */ +int virtsnd_pcm_msg_send(struct virtio_pcm_substream *vss) +{ + struct snd_pcm_runtime *runtime = vss->substream->runtime; + struct virtio_snd *snd = vss->snd; + struct virtio_device *vdev = snd->vdev; + struct virtqueue *vqueue = virtsnd_pcm_queue(vss)->vqueue; + int i; + int n; + bool notify = false; + + i = (vss->msg_last_enqueued + 1) % runtime->periods; + n = runtime->periods - vss->msg_count; + + for (; n; --n, i = (i + 1) % runtime->periods) { + struct virtio_pcm_msg *msg = vss->msgs[i]; + struct scatterlist *psgs[] = { + &msg->sgs[pcm_msg_sg_xfer], + &msg->sgs[pcm_msg_sg_data], + &msg->sgs[pcm_msg_sg_status] + }; + int rc; + + msg->xfer.stream_id = cpu_to_le32(vss->sid); + memset(&msg->status, 0, sizeof(msg->status)); + + if (vss->direction == sndrv_pcm_stream_playback) + rc = virtqueue_add_sgs(vqueue, psgs, 2, 1, msg, + gfp_atomic); + else + rc = virtqueue_add_sgs(vqueue, psgs, 1, 2, msg, + gfp_atomic); + + if (rc) { + dev_err(&vdev->dev, + "sid %u: failed to send i/o message ", + vss->sid); + return rc; + } + + vss->msg_last_enqueued = i; + vss->msg_count++; + } + + if (!(vss->features & (1u << virtio_snd_pcm_f_msg_polling))) + notify = virtqueue_kick_prepare(vqueue); + + if (notify) + virtqueue_notify(vqueue); + + return 0; +} + +/** + * virtsnd_pcm_msg_pending_num() - returns the number of pending i/o messages. + * @vss: virtio substream. + * + * context: any context. + * return: number of messages. + */ +unsigned int virtsnd_pcm_msg_pending_num(struct virtio_pcm_substream *vss) +{ + unsigned int num; + unsigned long flags; + + spin_lock_irqsave(&vss->lock, flags); + num = vss->msg_count; + spin_unlock_irqrestore(&vss->lock, flags); + + return num; +} + +/** + * virtsnd_pcm_msg_complete() - complete an i/o message. + * @msg: i/o message. + * @written_bytes: number of bytes written to the message. + * + * completion of the message means the elapsed period. if transmission is + * allowed, then each completed message is immediately placed back at the end + * of the queue. + * + * for the playback substream, @written_bytes is equal to sizeof(msg->status). + * + * for the capture substream, @written_bytes is equal to sizeof(msg->status) + * plus the number of captured bytes. + * + * context: interrupt context. takes and releases the virtio substream spinlock. + */ +static void virtsnd_pcm_msg_complete(struct virtio_pcm_msg *msg, + size_t written_bytes) +{ + struct virtio_pcm_substream *vss = msg->substream; + + /* + * hw_ptr always indicates the buffer position of the first i/o message + * in the virtqueue. therefore, on each completion of an i/o message, + * the hw_ptr value is unconditionally advanced. + */ + spin_lock(&vss->lock); + /* + * if the capture substream returned an incorrect status, then just + * increase the hw_ptr by the message size. + */ + if (vss->direction == sndrv_pcm_stream_playback || + written_bytes <= sizeof(msg->status)) + vss->hw_ptr += msg->length; + else + vss->hw_ptr += written_bytes - sizeof(msg->status); + + if (vss->hw_ptr >= vss->buffer_bytes) + vss->hw_ptr -= vss->buffer_bytes; + + vss->xfer_xrun = false; + vss->msg_count--; + + if (vss->xfer_enabled) { + struct snd_pcm_runtime *runtime = vss->substream->runtime; + + runtime->delay = + bytes_to_frames(runtime, + le32_to_cpu(msg->status.latency_bytes)); + + schedule_work(&vss->elapsed_period); + + virtsnd_pcm_msg_send(vss); + } else if (!vss->msg_count) { + wake_up_all(&vss->msg_empty); + } + spin_unlock(&vss->lock); +} + +/** + * virtsnd_pcm_notify_cb() - process all completed i/o messages. + * @queue: underlying tx/rx virtqueue. + * + * context: interrupt context. takes and releases the tx/rx queue spinlock. + */ +static inline void virtsnd_pcm_notify_cb(struct virtio_snd_queue *queue) +{ + struct virtio_pcm_msg *msg; + u32 written_bytes; + unsigned long flags; + + spin_lock_irqsave(&queue->lock, flags); + do { + virtqueue_disable_cb(queue->vqueue); + while ((msg = virtqueue_get_buf(queue->vqueue, &written_bytes))) + virtsnd_pcm_msg_complete(msg, written_bytes); + if (unlikely(virtqueue_is_broken(queue->vqueue))) + break; + } while (!virtqueue_enable_cb(queue->vqueue)); + spin_unlock_irqrestore(&queue->lock, flags); +} + +/** + * virtsnd_pcm_tx_notify_cb() - process all completed tx messages. + * @vqueue: underlying tx virtqueue. + * + * context: interrupt context. + */ +void virtsnd_pcm_tx_notify_cb(struct virtqueue *vqueue) +{ + struct virtio_snd *snd = vqueue->vdev->priv; + + virtsnd_pcm_notify_cb(virtsnd_tx_queue(snd)); +} + +/** + * virtsnd_pcm_rx_notify_cb() - process all completed rx messages. + * @vqueue: underlying rx virtqueue. + * + * context: interrupt context. + */ +void virtsnd_pcm_rx_notify_cb(struct virtqueue *vqueue) +{ + struct virtio_snd *snd = vqueue->vdev->priv; + + virtsnd_pcm_notify_cb(virtsnd_rx_queue(snd)); +} + +/** + * virtsnd_pcm_ctl_msg_alloc() - allocate and initialize the pcm device control + * message for the specified substream. + * @vss: virtio pcm substream. + * @command: control request code (virtio_snd_r_pcm_xxx). + * @gfp: kernel flags for memory allocation. + * + * context: any context. may sleep if @gfp flags permit. + * return: allocated message on success, null on failure. + */ +struct virtio_snd_msg * +virtsnd_pcm_ctl_msg_alloc(struct virtio_pcm_substream *vss, + unsigned int command, gfp_t gfp) +{ + size_t request_size = sizeof(struct virtio_snd_pcm_hdr); + size_t response_size = sizeof(struct virtio_snd_hdr); + struct virtio_snd_msg *msg; + + switch (command) { + case virtio_snd_r_pcm_set_params: + request_size = sizeof(struct virtio_snd_pcm_set_params); + break; + } + + msg = virtsnd_ctl_msg_alloc(request_size, response_size, gfp); + if (msg) { + struct virtio_snd_pcm_hdr *hdr = virtsnd_ctl_msg_request(msg); + + hdr->hdr.code = cpu_to_le32(command); + hdr->stream_id = cpu_to_le32(vss->sid); + } + + return msg; +}
|
Audio
|
f40a28679e0b7cb3a9cc6627a8dbb40961990f0a
|
anton yakovlev
|
sound
|
virtio
| |
alsa: virtio: pcm substream operators
|
introduce the operators required for the operation of substreams.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
(featured) add virtio sound driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'c', 'makefile']
| 4
| 454
| 1
|
--- diff --git a/sound/virtio/makefile b/sound/virtio/makefile --- a/sound/virtio/makefile +++ b/sound/virtio/makefile - virtio_pcm_msg.o + virtio_pcm_msg.o \ + virtio_pcm_ops.o diff --git a/sound/virtio/virtio_pcm.c b/sound/virtio/virtio_pcm.c --- a/sound/virtio/virtio_pcm.c +++ b/sound/virtio/virtio_pcm.c + + snd_pcm_set_ops(vpcm->pcm, i, &virtsnd_pcm_ops); diff --git a/sound/virtio/virtio_pcm.h b/sound/virtio/virtio_pcm.h --- a/sound/virtio/virtio_pcm.h +++ b/sound/virtio/virtio_pcm.h + * @stopped: true if the substream is stopped and must be released on the device + * side. + bool stopped; +extern const struct snd_pcm_ops virtsnd_pcm_ops; + diff --git a/sound/virtio/virtio_pcm_ops.c b/sound/virtio/virtio_pcm_ops.c --- /dev/null +++ b/sound/virtio/virtio_pcm_ops.c +// spdx-license-identifier: gpl-2.0+ +/* + * virtio-snd: virtio sound device + * copyright (c) 2021 opensynergy gmbh + */ +#include <sound/pcm_params.h> + +#include "virtio_card.h" + +/* + * i/o messages lifetime + * --------------------- + * + * allocation: + * messages are initially allocated in the ops->hw_params() after the size and + * number of periods have been successfully negotiated. + * + * freeing: + * messages can be safely freed after the queue has been successfully flushed + * (release command in the ops->sync_stop()) and the ops->hw_free() has been + * called. + * + * when the substream stops, the ops->sync_stop() waits until the device has + * completed all pending messages. this wait can be interrupted either by a + * signal or due to a timeout. in this case, the device can still access + * messages even after calling ops->hw_free(). it can also issue an interrupt, + * and the interrupt handler will also try to access message structures. + * + * therefore, freeing of already allocated messages occurs: + * + * - in ops->hw_params(), if this operator was called several times in a row, + * or if ops->hw_free() failed to free messages previously; + * + * - in ops->hw_free(), if the queue has been successfully flushed; + * + * - in dev->release(). + */ + +/* map for converting alsa format to virtio format. */ +struct virtsnd_a2v_format { + snd_pcm_format_t alsa_bit; + unsigned int vio_bit; +}; + +static const struct virtsnd_a2v_format g_a2v_format_map[] = { + { sndrv_pcm_format_ima_adpcm, virtio_snd_pcm_fmt_ima_adpcm }, + { sndrv_pcm_format_mu_law, virtio_snd_pcm_fmt_mu_law }, + { sndrv_pcm_format_a_law, virtio_snd_pcm_fmt_a_law }, + { sndrv_pcm_format_s8, virtio_snd_pcm_fmt_s8 }, + { sndrv_pcm_format_u8, virtio_snd_pcm_fmt_u8 }, + { sndrv_pcm_format_s16_le, virtio_snd_pcm_fmt_s16 }, + { sndrv_pcm_format_u16_le, virtio_snd_pcm_fmt_u16 }, + { sndrv_pcm_format_s18_3le, virtio_snd_pcm_fmt_s18_3 }, + { sndrv_pcm_format_u18_3le, virtio_snd_pcm_fmt_u18_3 }, + { sndrv_pcm_format_s20_3le, virtio_snd_pcm_fmt_s20_3 }, + { sndrv_pcm_format_u20_3le, virtio_snd_pcm_fmt_u20_3 }, + { sndrv_pcm_format_s24_3le, virtio_snd_pcm_fmt_s24_3 }, + { sndrv_pcm_format_u24_3le, virtio_snd_pcm_fmt_u24_3 }, + { sndrv_pcm_format_s20_le, virtio_snd_pcm_fmt_s20 }, + { sndrv_pcm_format_u20_le, virtio_snd_pcm_fmt_u20 }, + { sndrv_pcm_format_s24_le, virtio_snd_pcm_fmt_s24 }, + { sndrv_pcm_format_u24_le, virtio_snd_pcm_fmt_u24 }, + { sndrv_pcm_format_s32_le, virtio_snd_pcm_fmt_s32 }, + { sndrv_pcm_format_u32_le, virtio_snd_pcm_fmt_u32 }, + { sndrv_pcm_format_float_le, virtio_snd_pcm_fmt_float }, + { sndrv_pcm_format_float64_le, virtio_snd_pcm_fmt_float64 }, + { sndrv_pcm_format_dsd_u8, virtio_snd_pcm_fmt_dsd_u8 }, + { sndrv_pcm_format_dsd_u16_le, virtio_snd_pcm_fmt_dsd_u16 }, + { sndrv_pcm_format_dsd_u32_le, virtio_snd_pcm_fmt_dsd_u32 }, + { sndrv_pcm_format_iec958_subframe_le, + virtio_snd_pcm_fmt_iec958_subframe } +}; + +/* map for converting alsa frame rate to virtio frame rate. */ +struct virtsnd_a2v_rate { + unsigned int rate; + unsigned int vio_bit; +}; + +static const struct virtsnd_a2v_rate g_a2v_rate_map[] = { + { 5512, virtio_snd_pcm_rate_5512 }, + { 8000, virtio_snd_pcm_rate_8000 }, + { 11025, virtio_snd_pcm_rate_11025 }, + { 16000, virtio_snd_pcm_rate_16000 }, + { 22050, virtio_snd_pcm_rate_22050 }, + { 32000, virtio_snd_pcm_rate_32000 }, + { 44100, virtio_snd_pcm_rate_44100 }, + { 48000, virtio_snd_pcm_rate_48000 }, + { 64000, virtio_snd_pcm_rate_64000 }, + { 88200, virtio_snd_pcm_rate_88200 }, + { 96000, virtio_snd_pcm_rate_96000 }, + { 176400, virtio_snd_pcm_rate_176400 }, + { 192000, virtio_snd_pcm_rate_192000 } +}; + +static int virtsnd_pcm_sync_stop(struct snd_pcm_substream *substream); + +/** + * virtsnd_pcm_open() - open the pcm substream. + * @substream: kernel alsa substream. + * + * context: process context. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_pcm_open(struct snd_pcm_substream *substream) +{ + struct virtio_pcm *vpcm = snd_pcm_substream_chip(substream); + struct virtio_pcm_stream *vs = &vpcm->streams[substream->stream]; + struct virtio_pcm_substream *vss = vs->substreams[substream->number]; + + substream->runtime->hw = vss->hw; + substream->private_data = vss; + + snd_pcm_hw_constraint_integer(substream->runtime, + sndrv_pcm_hw_param_periods); + + vss->stopped = !!virtsnd_pcm_msg_pending_num(vss); + + /* + * if the substream has already been used, then the i/o queue may be in + * an invalid state. just in case, we do a check and try to return the + * queue to its original state, if necessary. + */ + return virtsnd_pcm_sync_stop(substream); +} + +/** + * virtsnd_pcm_close() - close the pcm substream. + * @substream: kernel alsa substream. + * + * context: process context. + * return: 0. + */ +static int virtsnd_pcm_close(struct snd_pcm_substream *substream) +{ + return 0; +} + +/** + * virtsnd_pcm_dev_set_params() - set the parameters of the pcm substream on + * the device side. + * @vss: virtio pcm substream. + * @buffer_bytes: size of the hardware buffer. + * @period_bytes: size of the hardware period. + * @channels: selected number of channels. + * @format: selected sample format (sndrv_pcm_format_xxx). + * @rate: selected frame rate. + * + * context: any context that permits to sleep. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_pcm_dev_set_params(struct virtio_pcm_substream *vss, + unsigned int buffer_bytes, + unsigned int period_bytes, + unsigned int channels, + snd_pcm_format_t format, + unsigned int rate) +{ + struct virtio_snd_msg *msg; + struct virtio_snd_pcm_set_params *request; + unsigned int i; + int vformat = -1; + int vrate = -1; + + for (i = 0; i < array_size(g_a2v_format_map); ++i) + if (g_a2v_format_map[i].alsa_bit == format) { + vformat = g_a2v_format_map[i].vio_bit; + + break; + } + + for (i = 0; i < array_size(g_a2v_rate_map); ++i) + if (g_a2v_rate_map[i].rate == rate) { + vrate = g_a2v_rate_map[i].vio_bit; + + break; + } + + if (vformat == -1 || vrate == -1) + return -einval; + + msg = virtsnd_pcm_ctl_msg_alloc(vss, virtio_snd_r_pcm_set_params, + gfp_kernel); + if (!msg) + return -enomem; + + request = virtsnd_ctl_msg_request(msg); + request->buffer_bytes = cpu_to_le32(buffer_bytes); + request->period_bytes = cpu_to_le32(period_bytes); + request->channels = channels; + request->format = vformat; + request->rate = vrate; + + if (vss->features & (1u << virtio_snd_pcm_f_msg_polling)) + request->features |= + cpu_to_le32(1u << virtio_snd_pcm_f_msg_polling); + + if (vss->features & (1u << virtio_snd_pcm_f_evt_xruns)) + request->features |= + cpu_to_le32(1u << virtio_snd_pcm_f_evt_xruns); + + return virtsnd_ctl_msg_send_sync(vss->snd, msg); +} + +/** + * virtsnd_pcm_hw_params() - set the parameters of the pcm substream. + * @substream: kernel alsa substream. + * @hw_params: hardware parameters. + * + * context: process context. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) +{ + struct virtio_pcm_substream *vss = snd_pcm_substream_chip(substream); + struct virtio_device *vdev = vss->snd->vdev; + int rc; + + if (virtsnd_pcm_msg_pending_num(vss)) { + dev_err(&vdev->dev, "sid %u: invalid i/o queue state ", + vss->sid); + return -ebadfd; + } + + rc = virtsnd_pcm_dev_set_params(vss, params_buffer_bytes(hw_params), + params_period_bytes(hw_params), + params_channels(hw_params), + params_format(hw_params), + params_rate(hw_params)); + if (rc) + return rc; + + /* + * free previously allocated messages if ops->hw_params() is called + * several times in a row, or if ops->hw_free() failed to free messages. + */ + virtsnd_pcm_msg_free(vss); + + return virtsnd_pcm_msg_alloc(vss, params_periods(hw_params), + params_period_bytes(hw_params)); +} + +/** + * virtsnd_pcm_hw_free() - reset the parameters of the pcm substream. + * @substream: kernel alsa substream. + * + * context: process context. + * return: 0 + */ +static int virtsnd_pcm_hw_free(struct snd_pcm_substream *substream) +{ + struct virtio_pcm_substream *vss = snd_pcm_substream_chip(substream); + + /* if the queue is flushed, we can safely free the messages here. */ + if (!virtsnd_pcm_msg_pending_num(vss)) + virtsnd_pcm_msg_free(vss); + + return 0; +} + +/** + * virtsnd_pcm_prepare() - prepare the pcm substream. + * @substream: kernel alsa substream. + * + * context: process context. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_pcm_prepare(struct snd_pcm_substream *substream) +{ + struct virtio_pcm_substream *vss = snd_pcm_substream_chip(substream); + struct virtio_device *vdev = vss->snd->vdev; + struct virtio_snd_msg *msg; + + if (virtsnd_pcm_msg_pending_num(vss)) { + dev_err(&vdev->dev, "sid %u: invalid i/o queue state ", + vss->sid); + return -ebadfd; + } + + vss->buffer_bytes = snd_pcm_lib_buffer_bytes(substream); + vss->hw_ptr = 0; + vss->xfer_xrun = false; + vss->msg_last_enqueued = -1; + vss->msg_count = 0; + + msg = virtsnd_pcm_ctl_msg_alloc(vss, virtio_snd_r_pcm_prepare, + gfp_kernel); + if (!msg) + return -enomem; + + return virtsnd_ctl_msg_send_sync(vss->snd, msg); +} + +/** + * virtsnd_pcm_trigger() - process command for the pcm substream. + * @substream: kernel alsa substream. + * @command: substream command (sndrv_pcm_trigger_xxx). + * + * context: any context. takes and releases the virtio substream spinlock. + * may take and release the tx/rx queue spinlock. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_pcm_trigger(struct snd_pcm_substream *substream, int command) +{ + struct virtio_pcm_substream *vss = snd_pcm_substream_chip(substream); + struct virtio_snd *snd = vss->snd; + struct virtio_snd_queue *queue; + struct virtio_snd_msg *msg; + unsigned long flags; + int rc; + + switch (command) { + case sndrv_pcm_trigger_start: + case sndrv_pcm_trigger_pause_release: + queue = virtsnd_pcm_queue(vss); + + spin_lock_irqsave(&queue->lock, flags); + spin_lock(&vss->lock); + rc = virtsnd_pcm_msg_send(vss); + if (!rc) + vss->xfer_enabled = true; + spin_unlock(&vss->lock); + spin_unlock_irqrestore(&queue->lock, flags); + if (rc) + return rc; + + msg = virtsnd_pcm_ctl_msg_alloc(vss, virtio_snd_r_pcm_start, + gfp_kernel); + if (!msg) { + spin_lock_irqsave(&vss->lock, flags); + vss->xfer_enabled = false; + spin_unlock_irqrestore(&vss->lock, flags); + + return -enomem; + } + + return virtsnd_ctl_msg_send_sync(snd, msg); + case sndrv_pcm_trigger_stop: + vss->stopped = true; + fallthrough; + case sndrv_pcm_trigger_pause_push: + spin_lock_irqsave(&vss->lock, flags); + vss->xfer_enabled = false; + spin_unlock_irqrestore(&vss->lock, flags); + + msg = virtsnd_pcm_ctl_msg_alloc(vss, virtio_snd_r_pcm_stop, + gfp_kernel); + if (!msg) + return -enomem; + + return virtsnd_ctl_msg_send_sync(snd, msg); + default: + return -einval; + } +} + +/** + * virtsnd_pcm_sync_stop() - synchronous pcm substream stop. + * @substream: kernel alsa substream. + * + * the function can be called both from the upper level or from the driver + * itself. + * + * context: process context. takes and releases the virtio substream spinlock. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_pcm_sync_stop(struct snd_pcm_substream *substream) +{ + struct virtio_pcm_substream *vss = snd_pcm_substream_chip(substream); + struct virtio_snd *snd = vss->snd; + struct virtio_snd_msg *msg; + unsigned int js = msecs_to_jiffies(virtsnd_msg_timeout_ms); + int rc; + + cancel_work_sync(&vss->elapsed_period); + + if (!vss->stopped) + return 0; + + msg = virtsnd_pcm_ctl_msg_alloc(vss, virtio_snd_r_pcm_release, + gfp_kernel); + if (!msg) + return -enomem; + + rc = virtsnd_ctl_msg_send_sync(snd, msg); + if (rc) + return rc; + + /* + * the spec states that upon receipt of the release command "the device + * must complete all pending i/o messages for the specified stream id". + * thus, we consider the absence of i/o messages in the queue as an + * indication that the substream has been released. + */ + rc = wait_event_interruptible_timeout(vss->msg_empty, + !virtsnd_pcm_msg_pending_num(vss), + js); + if (rc <= 0) { + dev_warn(&snd->vdev->dev, "sid %u: failed to flush i/o queue ", + vss->sid); + + return !rc ? -etimedout : rc; + } + + vss->stopped = false; + + return 0; +} + +/** + * virtsnd_pcm_pointer() - get the current hardware position for the pcm + * substream. + * @substream: kernel alsa substream. + * + * context: any context. takes and releases the virtio substream spinlock. + * return: hardware position in frames inside [0 ... buffer_size) range. + */ +static snd_pcm_uframes_t +virtsnd_pcm_pointer(struct snd_pcm_substream *substream) +{ + struct virtio_pcm_substream *vss = snd_pcm_substream_chip(substream); + snd_pcm_uframes_t hw_ptr = sndrv_pcm_pos_xrun; + unsigned long flags; + + spin_lock_irqsave(&vss->lock, flags); + if (!vss->xfer_xrun) + hw_ptr = bytes_to_frames(substream->runtime, vss->hw_ptr); + spin_unlock_irqrestore(&vss->lock, flags); + + return hw_ptr; +} + +/* pcm substream operators map. */ +const struct snd_pcm_ops virtsnd_pcm_ops = { + .open = virtsnd_pcm_open, + .close = virtsnd_pcm_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = virtsnd_pcm_hw_params, + .hw_free = virtsnd_pcm_hw_free, + .prepare = virtsnd_pcm_prepare, + .trigger = virtsnd_pcm_trigger, + .sync_stop = virtsnd_pcm_sync_stop, + .pointer = virtsnd_pcm_pointer, +};
|
Audio
|
da76e9f3e43a7195c69d370ee514cccae6517c76
|
anton yakovlev
|
sound
|
virtio
| |
alsa: virtio: introduce jack support
|
enumerate all available jacks and create alsa controls.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
(featured) add virtio sound driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'c', 'makefile']
| 4
| 260
| 0
|
--- diff --git a/sound/virtio/makefile b/sound/virtio/makefile --- a/sound/virtio/makefile +++ b/sound/virtio/makefile + virtio_jack.o \ diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c --- a/sound/virtio/virtio_card.c +++ b/sound/virtio/virtio_card.c + case virtio_snd_evt_jack_connected: + case virtio_snd_evt_jack_disconnected: + virtsnd_jack_event(snd, event); + break; + rc = virtsnd_jack_parse_cfg(snd); + if (rc) + return rc; + + if (snd->njacks) { + rc = virtsnd_jack_build_devs(snd); + if (rc) + return rc; + } + diff --git a/sound/virtio/virtio_card.h b/sound/virtio/virtio_card.h --- a/sound/virtio/virtio_card.h +++ b/sound/virtio/virtio_card.h +struct virtio_jack; + * @jacks: virtio jacks. + * @njacks: number of jacks. + struct virtio_jack *jacks; + u32 njacks; +int virtsnd_jack_parse_cfg(struct virtio_snd *snd); + +int virtsnd_jack_build_devs(struct virtio_snd *snd); + +void virtsnd_jack_event(struct virtio_snd *snd, + struct virtio_snd_event *event); + diff --git a/sound/virtio/virtio_jack.c b/sound/virtio/virtio_jack.c --- /dev/null +++ b/sound/virtio/virtio_jack.c +// spdx-license-identifier: gpl-2.0+ +/* + * virtio-snd: virtio sound device + * copyright (c) 2021 opensynergy gmbh + */ +#include <linux/virtio_config.h> +#include <sound/jack.h> +#include <sound/hda_verbs.h> + +#include "virtio_card.h" + +/** + * doc: implementation status + * + * at the moment jacks have a simple implementation and can only be used to + * receive notifications about a plugged in/out device. + * + * virtio_snd_r_jack_remap + * is not supported + */ + +/** + * struct virtio_jack - virtio jack. + * @jack: kernel jack control. + * @nid: functional group node identifier. + * @features: jack virtio feature bit map (1 << virtio_snd_jack_f_xxx). + * @defconf: pin default configuration value. + * @caps: pin capabilities value. + * @connected: current jack connection status. + * @type: kernel jack type (snd_jack_xxx). + */ +struct virtio_jack { + struct snd_jack *jack; + u32 nid; + u32 features; + u32 defconf; + u32 caps; + bool connected; + int type; +}; + +/** + * virtsnd_jack_get_label() - get the name string for the jack. + * @vjack: virtio jack. + * + * returns the jack name based on the default pin configuration value (see hda + * specification). + * + * context: any context. + * return: name string. + */ +static const char *virtsnd_jack_get_label(struct virtio_jack *vjack) +{ + unsigned int defconf = vjack->defconf; + unsigned int device = + (defconf & ac_defcfg_device) >> ac_defcfg_device_shift; + unsigned int location = + (defconf & ac_defcfg_location) >> ac_defcfg_location_shift; + + switch (device) { + case ac_jack_line_out: + return "line out"; + case ac_jack_speaker: + return "speaker"; + case ac_jack_hp_out: + return "headphone"; + case ac_jack_cd: + return "cd"; + case ac_jack_spdif_out: + case ac_jack_dig_other_out: + if (location == ac_jack_loc_hdmi) + return "hdmi out"; + else + return "spdif out"; + case ac_jack_line_in: + return "line"; + case ac_jack_aux: + return "aux"; + case ac_jack_mic_in: + return "mic"; + case ac_jack_spdif_in: + return "spdif in"; + case ac_jack_dig_other_in: + return "digital in"; + default: + return "misc"; + } +} + +/** + * virtsnd_jack_get_type() - get the type for the jack. + * @vjack: virtio jack. + * + * returns the jack type based on the default pin configuration value (see hda + * specification). + * + * context: any context. + * return: snd_jack_xxx value. + */ +static int virtsnd_jack_get_type(struct virtio_jack *vjack) +{ + unsigned int defconf = vjack->defconf; + unsigned int device = + (defconf & ac_defcfg_device) >> ac_defcfg_device_shift; + + switch (device) { + case ac_jack_line_out: + case ac_jack_speaker: + return snd_jack_lineout; + case ac_jack_hp_out: + return snd_jack_headphone; + case ac_jack_spdif_out: + case ac_jack_dig_other_out: + return snd_jack_avout; + case ac_jack_mic_in: + return snd_jack_microphone; + default: + return snd_jack_linein; + } +} + +/** + * virtsnd_jack_parse_cfg() - parse the jack configuration. + * @snd: virtio sound device. + * + * this function is called during initial device initialization. + * + * context: any context that permits to sleep. + * return: 0 on success, -errno on failure. + */ +int virtsnd_jack_parse_cfg(struct virtio_snd *snd) +{ + struct virtio_device *vdev = snd->vdev; + struct virtio_snd_jack_info *info; + u32 i; + int rc; + + virtio_cread_le(vdev, struct virtio_snd_config, jacks, &snd->njacks); + if (!snd->njacks) + return 0; + + snd->jacks = devm_kcalloc(&vdev->dev, snd->njacks, sizeof(*snd->jacks), + gfp_kernel); + if (!snd->jacks) + return -enomem; + + info = kcalloc(snd->njacks, sizeof(*info), gfp_kernel); + if (!info) + return -enomem; + + rc = virtsnd_ctl_query_info(snd, virtio_snd_r_jack_info, 0, snd->njacks, + sizeof(*info), info); + if (rc) + goto on_exit; + + for (i = 0; i < snd->njacks; ++i) { + struct virtio_jack *vjack = &snd->jacks[i]; + + vjack->nid = le32_to_cpu(info[i].hdr.hda_fn_nid); + vjack->features = le32_to_cpu(info[i].features); + vjack->defconf = le32_to_cpu(info[i].hda_reg_defconf); + vjack->caps = le32_to_cpu(info[i].hda_reg_caps); + vjack->connected = info[i].connected; + } + +on_exit: + kfree(info); + + return rc; +} + +/** + * virtsnd_jack_build_devs() - build alsa controls for jacks. + * @snd: virtio sound device. + * + * context: any context that permits to sleep. + * return: 0 on success, -errno on failure. + */ +int virtsnd_jack_build_devs(struct virtio_snd *snd) +{ + u32 i; + int rc; + + for (i = 0; i < snd->njacks; ++i) { + struct virtio_jack *vjack = &snd->jacks[i]; + + vjack->type = virtsnd_jack_get_type(vjack); + + rc = snd_jack_new(snd->card, virtsnd_jack_get_label(vjack), + vjack->type, &vjack->jack, true, true); + if (rc) + return rc; + + if (vjack->jack) + vjack->jack->private_data = vjack; + + snd_jack_report(vjack->jack, + vjack->connected ? vjack->type : 0); + } + + return 0; +} + +/** + * virtsnd_jack_event() - handle the jack event notification. + * @snd: virtio sound device. + * @event: virtio sound event. + * + * context: interrupt context. + */ +void virtsnd_jack_event(struct virtio_snd *snd, struct virtio_snd_event *event) +{ + u32 jack_id = le32_to_cpu(event->data); + struct virtio_jack *vjack; + + if (jack_id >= snd->njacks) + return; + + vjack = &snd->jacks[jack_id]; + + switch (le32_to_cpu(event->hdr.code)) { + case virtio_snd_evt_jack_connected: + vjack->connected = true; + break; + case virtio_snd_evt_jack_disconnected: + vjack->connected = false; + break; + default: + return; + } + + snd_jack_report(vjack->jack, vjack->connected ? vjack->type : 0); +}
|
Audio
|
ca61a41f389c80db091db9d4ad5a651e2b4c9f70
|
anton yakovlev
|
sound
|
virtio
| |
alsa: virtio: introduce pcm channel map support
|
enumerate all available pcm channel maps and create alsa controls.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
(featured) add virtio sound driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'c', 'makefile']
| 5
| 242
| 0
|
--- diff --git a/sound/virtio/makefile b/sound/virtio/makefile --- a/sound/virtio/makefile +++ b/sound/virtio/makefile + virtio_chmap.o \ diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c --- a/sound/virtio/virtio_card.c +++ b/sound/virtio/virtio_card.c + rc = virtsnd_chmap_parse_cfg(snd); + if (rc) + return rc; + + if (snd->nchmaps) { + rc = virtsnd_chmap_build_devs(snd); + if (rc) + return rc; + } + diff --git a/sound/virtio/virtio_card.h b/sound/virtio/virtio_card.h --- a/sound/virtio/virtio_card.h +++ b/sound/virtio/virtio_card.h + * @chmaps: virtio channel maps. + * @nchmaps: number of channel maps. + struct virtio_snd_chmap_info *chmaps; + u32 nchmaps; +int virtsnd_chmap_parse_cfg(struct virtio_snd *snd); + +int virtsnd_chmap_build_devs(struct virtio_snd *snd); + diff --git a/sound/virtio/virtio_chmap.c b/sound/virtio/virtio_chmap.c --- /dev/null +++ b/sound/virtio/virtio_chmap.c +// spdx-license-identifier: gpl-2.0+ +/* + * virtio-snd: virtio sound device + * copyright (c) 2021 opensynergy gmbh + */ +#include <linux/virtio_config.h> + +#include "virtio_card.h" + +/* virtio->alsa channel position map */ +static const u8 g_v2a_position_map[] = { + [virtio_snd_chmap_none] = sndrv_chmap_unknown, + [virtio_snd_chmap_na] = sndrv_chmap_na, + [virtio_snd_chmap_mono] = sndrv_chmap_mono, + [virtio_snd_chmap_fl] = sndrv_chmap_fl, + [virtio_snd_chmap_fr] = sndrv_chmap_fr, + [virtio_snd_chmap_rl] = sndrv_chmap_rl, + [virtio_snd_chmap_rr] = sndrv_chmap_rr, + [virtio_snd_chmap_fc] = sndrv_chmap_fc, + [virtio_snd_chmap_lfe] = sndrv_chmap_lfe, + [virtio_snd_chmap_sl] = sndrv_chmap_sl, + [virtio_snd_chmap_sr] = sndrv_chmap_sr, + [virtio_snd_chmap_rc] = sndrv_chmap_rc, + [virtio_snd_chmap_flc] = sndrv_chmap_flc, + [virtio_snd_chmap_frc] = sndrv_chmap_frc, + [virtio_snd_chmap_rlc] = sndrv_chmap_rlc, + [virtio_snd_chmap_rrc] = sndrv_chmap_rrc, + [virtio_snd_chmap_flw] = sndrv_chmap_flw, + [virtio_snd_chmap_frw] = sndrv_chmap_frw, + [virtio_snd_chmap_flh] = sndrv_chmap_flh, + [virtio_snd_chmap_fch] = sndrv_chmap_fch, + [virtio_snd_chmap_frh] = sndrv_chmap_frh, + [virtio_snd_chmap_tc] = sndrv_chmap_tc, + [virtio_snd_chmap_tfl] = sndrv_chmap_tfl, + [virtio_snd_chmap_tfr] = sndrv_chmap_tfr, + [virtio_snd_chmap_tfc] = sndrv_chmap_tfc, + [virtio_snd_chmap_trl] = sndrv_chmap_trl, + [virtio_snd_chmap_trr] = sndrv_chmap_trr, + [virtio_snd_chmap_trc] = sndrv_chmap_trc, + [virtio_snd_chmap_tflc] = sndrv_chmap_tflc, + [virtio_snd_chmap_tfrc] = sndrv_chmap_tfrc, + [virtio_snd_chmap_tsl] = sndrv_chmap_tsl, + [virtio_snd_chmap_tsr] = sndrv_chmap_tsr, + [virtio_snd_chmap_llfe] = sndrv_chmap_llfe, + [virtio_snd_chmap_rlfe] = sndrv_chmap_rlfe, + [virtio_snd_chmap_bc] = sndrv_chmap_bc, + [virtio_snd_chmap_blc] = sndrv_chmap_blc, + [virtio_snd_chmap_brc] = sndrv_chmap_brc +}; + +/** + * virtsnd_chmap_parse_cfg() - parse the channel map configuration. + * @snd: virtio sound device. + * + * this function is called during initial device initialization. + * + * context: any context that permits to sleep. + * return: 0 on success, -errno on failure. + */ +int virtsnd_chmap_parse_cfg(struct virtio_snd *snd) +{ + struct virtio_device *vdev = snd->vdev; + u32 i; + int rc; + + virtio_cread_le(vdev, struct virtio_snd_config, chmaps, &snd->nchmaps); + if (!snd->nchmaps) + return 0; + + snd->chmaps = devm_kcalloc(&vdev->dev, snd->nchmaps, + sizeof(*snd->chmaps), gfp_kernel); + if (!snd->chmaps) + return -enomem; + + rc = virtsnd_ctl_query_info(snd, virtio_snd_r_chmap_info, 0, + snd->nchmaps, sizeof(*snd->chmaps), + snd->chmaps); + if (rc) + return rc; + + /* count the number of channel maps per each pcm device/stream. */ + for (i = 0; i < snd->nchmaps; ++i) { + struct virtio_snd_chmap_info *info = &snd->chmaps[i]; + u32 nid = le32_to_cpu(info->hdr.hda_fn_nid); + struct virtio_pcm *vpcm; + struct virtio_pcm_stream *vs; + + vpcm = virtsnd_pcm_find_or_create(snd, nid); + if (is_err(vpcm)) + return ptr_err(vpcm); + + switch (info->direction) { + case virtio_snd_d_output: + vs = &vpcm->streams[sndrv_pcm_stream_playback]; + break; + case virtio_snd_d_input: + vs = &vpcm->streams[sndrv_pcm_stream_capture]; + break; + default: + dev_err(&vdev->dev, + "chmap #%u: unknown direction (%u) ", i, + info->direction); + return -einval; + } + + vs->nchmaps++; + } + + return 0; +} + +/** + * virtsnd_chmap_add_ctls() - create an alsa control for channel maps. + * @pcm: alsa pcm device. + * @direction: pcm stream direction (sndrv_pcm_stream_xxx). + * @vs: virtio pcm stream. + * + * context: any context. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_chmap_add_ctls(struct snd_pcm *pcm, int direction, + struct virtio_pcm_stream *vs) +{ + u32 i; + int max_channels = 0; + + for (i = 0; i < vs->nchmaps; i++) + if (max_channels < vs->chmaps[i].channels) + max_channels = vs->chmaps[i].channels; + + return snd_pcm_add_chmap_ctls(pcm, direction, vs->chmaps, max_channels, + 0, null); +} + +/** + * virtsnd_chmap_build_devs() - build alsa controls for channel maps. + * @snd: virtio sound device. + * + * context: any context. + * return: 0 on success, -errno on failure. + */ +int virtsnd_chmap_build_devs(struct virtio_snd *snd) +{ + struct virtio_device *vdev = snd->vdev; + struct virtio_pcm *vpcm; + struct virtio_pcm_stream *vs; + u32 i; + int rc; + + /* allocate channel map elements per each pcm device/stream. */ + list_for_each_entry(vpcm, &snd->pcm_list, list) { + for (i = 0; i < array_size(vpcm->streams); ++i) { + vs = &vpcm->streams[i]; + + if (!vs->nchmaps) + continue; + + vs->chmaps = devm_kcalloc(&vdev->dev, vs->nchmaps + 1, + sizeof(*vs->chmaps), + gfp_kernel); + if (!vs->chmaps) + return -enomem; + + vs->nchmaps = 0; + } + } + + /* initialize channel maps per each pcm device/stream. */ + for (i = 0; i < snd->nchmaps; ++i) { + struct virtio_snd_chmap_info *info = &snd->chmaps[i]; + unsigned int channels = info->channels; + unsigned int ch; + struct snd_pcm_chmap_elem *chmap; + + vpcm = virtsnd_pcm_find(snd, le32_to_cpu(info->hdr.hda_fn_nid)); + if (is_err(vpcm)) + return ptr_err(vpcm); + + if (info->direction == virtio_snd_d_output) + vs = &vpcm->streams[sndrv_pcm_stream_playback]; + else + vs = &vpcm->streams[sndrv_pcm_stream_capture]; + + chmap = &vs->chmaps[vs->nchmaps++]; + + if (channels > array_size(chmap->map)) + channels = array_size(chmap->map); + + chmap->channels = channels; + + for (ch = 0; ch < channels; ++ch) { + u8 position = info->positions[ch]; + + if (position >= array_size(g_v2a_position_map)) + return -einval; + + chmap->map[ch] = g_v2a_position_map[position]; + } + } + + /* create an alsa control per each pcm device/stream. */ + list_for_each_entry(vpcm, &snd->pcm_list, list) { + if (!vpcm->pcm) + continue; + + for (i = 0; i < array_size(vpcm->streams); ++i) { + vs = &vpcm->streams[i]; + + if (!vs->nchmaps) + continue; + + rc = virtsnd_chmap_add_ctls(vpcm->pcm, i, vs); + if (rc) + return rc; + } + } + + return 0; +} diff --git a/sound/virtio/virtio_pcm.h b/sound/virtio/virtio_pcm.h --- a/sound/virtio/virtio_pcm.h +++ b/sound/virtio/virtio_pcm.h + * @chmaps: kernel channel maps belonging to the stream. + * @nchmaps: number of channel maps. + struct snd_pcm_chmap_elem *chmaps; + u32 nchmaps;
|
Audio
|
19325fedf245ca932c58a629d3888a9a393534ab
|
anton yakovlev
|
sound
|
virtio
| |
alsa: virtio: introduce device suspend/resume support
|
all running pcm substreams are stopped on device suspend and restarted on device resume.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
(featured) add virtio sound driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
[]
|
['h', 'c']
| 3
| 85
| 7
|
--- diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c --- a/sound/virtio/virtio_card.c +++ b/sound/virtio/virtio_card.c +#ifdef config_pm_sleep +/** + * virtsnd_freeze() - suspend device. + * @vdev: virtio parent device. + * + * context: any context. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_freeze(struct virtio_device *vdev) +{ + struct virtio_snd *snd = vdev->priv; + unsigned int i; + + virtsnd_disable_event_vq(snd); + virtsnd_ctl_msg_cancel_all(snd); + + vdev->config->del_vqs(vdev); + vdev->config->reset(vdev); + + for (i = 0; i < snd->nsubstreams; ++i) + cancel_work_sync(&snd->substreams[i].elapsed_period); + + kfree(snd->event_msgs); + snd->event_msgs = null; + + return 0; +} + +/** + * virtsnd_restore() - resume device. + * @vdev: virtio parent device. + * + * context: any context. + * return: 0 on success, -errno on failure. + */ +static int virtsnd_restore(struct virtio_device *vdev) +{ + struct virtio_snd *snd = vdev->priv; + int rc; + + rc = virtsnd_find_vqs(snd); + if (rc) + return rc; + + virtio_device_ready(vdev); + + virtsnd_enable_event_vq(snd); + + return 0; +} +#endif /* config_pm_sleep */ + +#ifdef config_pm_sleep + .freeze = virtsnd_freeze, + .restore = virtsnd_restore, +#endif diff --git a/sound/virtio/virtio_pcm.h b/sound/virtio/virtio_pcm.h --- a/sound/virtio/virtio_pcm.h +++ b/sound/virtio/virtio_pcm.h + * @suspended: true if the substream is suspended and must be reconfigured on + * the device side at resume. + bool suspended; diff --git a/sound/virtio/virtio_pcm_ops.c b/sound/virtio/virtio_pcm_ops.c --- a/sound/virtio/virtio_pcm_ops.c +++ b/sound/virtio/virtio_pcm_ops.c + vss->suspended = false; - if (virtsnd_pcm_msg_pending_num(vss)) { - dev_err(&vdev->dev, "sid %u: invalid i/o queue state ", - vss->sid); - return -ebadfd; + if (!vss->suspended) { + if (virtsnd_pcm_msg_pending_num(vss)) { + dev_err(&vdev->dev, "sid %u: invalid i/o queue state ", + vss->sid); + return -ebadfd; + } + + vss->buffer_bytes = snd_pcm_lib_buffer_bytes(substream); + vss->hw_ptr = 0; + vss->msg_last_enqueued = -1; + } else { + struct snd_pcm_runtime *runtime = substream->runtime; + unsigned int buffer_bytes = snd_pcm_lib_buffer_bytes(substream); + unsigned int period_bytes = snd_pcm_lib_period_bytes(substream); + int rc; + + rc = virtsnd_pcm_dev_set_params(vss, buffer_bytes, period_bytes, + runtime->channels, + runtime->format, runtime->rate); + if (rc) + return rc; - vss->buffer_bytes = snd_pcm_lib_buffer_bytes(substream); - vss->hw_ptr = 0; - vss->msg_last_enqueued = -1; + vss->suspended = false; + case sndrv_pcm_trigger_suspend: + vss->suspended = true; + fallthrough;
|
Audio
|
575483e90a3292c2afceb7161732046e411d6fdd
|
anton yakovlev
|
sound
|
virtio
| |
asoc: intel: add max98390 echo reference support
|
load new topology file with speaker capture pipeline.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add max98390 echo reference support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'intel']
|
['c']
| 1
| 1
| 1
|
--- diff --git a/sound/soc/intel/common/soc-acpi-intel-cml-match.c b/sound/soc/intel/common/soc-acpi-intel-cml-match.c --- a/sound/soc/intel/common/soc-acpi-intel-cml-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cml-match.c - .sof_tplg_filename = "sof-cml-da7219-max98357a.tplg", + .sof_tplg_filename = "sof-cml-da7219-max98390.tplg",
|
Audio
|
c7721e94279887f9dd8f4be303f2054bb5477c9e
|
mac chiang pierre louis bossart pierre louis bossart linux intel com
|
sound
|
soc
|
common, intel
|
asoc: intel: board: add be dai link for wov
|
create dai link in kbl_da7219_max98357a driver for wake on voice functionality.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add be dai link for wov
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'intel', 'board']
|
['c']
| 1
| 48
| 0
|
--- diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c --- a/sound/soc/intel/boards/kbl_da7219_max98357a.c +++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c + kbl_dpcm_audio_ref_cp, +static unsigned int rates_16000[] = { + 16000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_16000 = { + .count = array_size(rates_16000), + .list = rates_16000, +}; + +static const unsigned int ch_mono[] = { + 1, +}; + +static const struct snd_pcm_hw_constraint_list constraints_refcap = { + .count = array_size(ch_mono), + .list = ch_mono, +}; + +static int kabylake_refcap_startup(struct snd_pcm_substream *substream) +{ + substream->runtime->hw.channels_max = 1; + snd_pcm_hw_constraint_list(substream->runtime, 0, + sndrv_pcm_hw_param_channels, + &constraints_refcap); + + return snd_pcm_hw_constraint_list(substream->runtime, 0, + sndrv_pcm_hw_param_rate, + &constraints_16000); +} + +static struct snd_soc_ops skylake_refcap_ops = { + .startup = kabylake_refcap_startup, +}; + +snd_soc_dailink_def(reference, + dailink_comp_array(comp_cpu("reference pin"))); + + [kbl_dpcm_audio_ref_cp] = { + .name = "kbl audio reference cap", + .stream_name = "wake on voice", + .init = null, + .dpcm_capture = 1, + .nonatomic = 1, + .dynamic = 1, + .ops = &skylake_refcap_ops, + snd_soc_dailink_reg(reference, dummy, platform), + },
|
Audio
|
74ed9e9bfb7343b0a6710b651df66f3d68551110
|
mac chiang
|
sound
|
soc
|
boards, intel
|
asoc: intel: bytcr_wm5102: add jack detect support
|
add jack detect support by creating a jack and calling snd_soc_component_set_jack to register the created jack with the codec.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add jack detect support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'intel', 'bytcr_wm5102']
|
['c']
| 1
| 27
| 1
|
--- diff --git a/sound/soc/intel/boards/bytcr_wm5102.c b/sound/soc/intel/boards/bytcr_wm5102.c --- a/sound/soc/intel/boards/bytcr_wm5102.c +++ b/sound/soc/intel/boards/bytcr_wm5102.c +#include <sound/jack.h> + struct snd_soc_jack jack; +static struct snd_soc_jack_pin byt_wm5102_pins[] = { + { + .pin = "headphone", + .mask = snd_jack_headphone, + }, + { + .pin = "headset mic", + .mask = snd_jack_microphone, + }, +}; + - int ret; + struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component; + int ret, jack_type; + jack_type = arizona_jack_mask | snd_jack_btn_0 | snd_jack_btn_1 | + snd_jack_btn_2 | snd_jack_btn_3; + ret = snd_soc_card_jack_new(card, "headset", jack_type, + &priv->jack, byt_wm5102_pins, + array_size(byt_wm5102_pins)); + if (ret) { + dev_err(card->dev, "error creating jack: %d ", ret); + return ret; + } + + snd_soc_component_set_jack(component, &priv->jack, null); +
|
Audio
|
ecd77d494ec995fb07102b408954c94f38374084
|
hans de goede andy shevchenko andy shevchenko gmail com
|
sound
|
soc
|
boards, intel
|
asoc: intel: cht_bsw_rt5672: add support for bay trail cr / ssp0
|
the rt5672 codec is used on some bay trail cr boards, on these socs ssp2 is not available and ssp0 should be used instead. at support for this.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for bay trail cr / ssp0
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'intel', 'cht_bsw_rt5672']
|
['c']
| 1
| 61
| 14
|
--- diff --git a/sound/soc/intel/boards/cht_bsw_rt5672.c b/sound/soc/intel/boards/cht_bsw_rt5672.c --- a/sound/soc/intel/boards/cht_bsw_rt5672.c +++ b/sound/soc/intel/boards/cht_bsw_rt5672.c +#include "../common/soc-intel-quirks.h" + bool use_ssp0; + {"headphone", null, "platform clock"}, + {"headset mic", null, "platform clock"}, + {"int mic", null, "platform clock"}, + {"ext spk", null, "platform clock"}, +}; + +static const struct snd_soc_dapm_route cht_audio_ssp0_map[] = { + {"aif1 playback", null, "ssp0 tx"}, + {"ssp0 tx", null, "modem_out"}, + {"modem_in", null, "ssp0 rx"}, + {"ssp0 rx", null, "aif1 capture"}, +}; + +static const struct snd_soc_dapm_route cht_audio_ssp2_map[] = { - {"headphone", null, "platform clock"}, - {"headset mic", null, "platform clock"}, - {"int mic", null, "platform clock"}, - {"ext spk", null, "platform clock"}, + if (ctx->use_ssp0) { + ret = snd_soc_dapm_add_routes(&runtime->card->dapm, + cht_audio_ssp0_map, + array_size(cht_audio_ssp0_map)); + } else { + ret = snd_soc_dapm_add_routes(&runtime->card->dapm, + cht_audio_ssp2_map, + array_size(cht_audio_ssp2_map)); + } + if (ret) + return ret; + + struct cht_mc_private *ctx = snd_soc_card_get_drvdata(rtd->card); - int ret; + int ret, bits; - /* set ssp2 to 24-bit */ - params_set_format(params, sndrv_pcm_format_s24_le); + if (ctx->use_ssp0) { + /* set ssp0 to 16-bit */ + params_set_format(params, sndrv_pcm_format_s16_le); + bits = 16; + } else { + /* set ssp2 to 24-bit */ + params_set_format(params, sndrv_pcm_format_s24_le); + bits = 24; + } + ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_cpu(rtd, 0), 0x3, 0x3, 2, bits); + if (ret < 0) { + dev_err(rtd->dev, "can't set i2s config, err %d ", ret); + return ret; + } + + int dai_index = 0; + /* find index of codec dai */ + for (i = 0; i < array_size(cht_dailink); i++) { + if (!strcmp(cht_dailink[i].codecs->name, rt5672_i2c_default)) { + dai_index = i; + break; + } + } + - for (i = 0; i < array_size(cht_dailink); i++) { - if (!strcmp(cht_dailink[i].codecs->name, - rt5672_i2c_default)) { - cht_dailink[i].codecs->name = drv->codec_name; - break; - } - } + cht_dailink[dai_index].codecs->name = drv->codec_name; + } + + /* use ssp0 on bay trail cr devices */ + if (soc_intel_is_byt() && mach->mach_params.acpi_ipc_irq_index == 0) { + cht_dailink[dai_index].cpus->dai_name = "ssp0-port"; + drv->use_ssp0 = true;
|
Audio
|
c9b3c63392e578ea74411b29a720ace77ae9041f
|
hans de goede
|
sound
|
soc
|
boards, intel
|
asoc: intel: soc-acpi: add adl soundwire base configurations
|
add configurations ported over from tgl.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add adl jack-less soundwire configurations
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'intel', 'soc-acpi']
|
['c']
| 1
| 185
| 0
|
--- diff --git a/sound/soc/intel/common/soc-acpi-intel-adl-match.c b/sound/soc/intel/common/soc-acpi-intel-adl-match.c --- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c +static const struct snd_soc_acpi_endpoint spk_l_endpoint = { + .num = 0, + .aggregated = 1, + .group_position = 0, + .group_id = 1, +}; + +static const struct snd_soc_acpi_endpoint spk_r_endpoint = { + .num = 0, + .aggregated = 1, + .group_position = 1, + .group_id = 1, +}; + +static const struct snd_soc_acpi_adr_device rt1308_1_group1_adr[] = { + { + .adr = 0x000120025d130800, + .num_endpoints = 1, + .endpoints = &spk_l_endpoint, + .name_prefix = "rt1308-1" + } +}; + +static const struct snd_soc_acpi_adr_device rt1308_2_group1_adr[] = { + { + .adr = 0x000220025d130800, + .num_endpoints = 1, + .endpoints = &spk_r_endpoint, + .name_prefix = "rt1308-2" + } +}; + +static const struct snd_soc_acpi_adr_device rt715_3_adr[] = { + { + .adr = 0x000320025d071500, + .num_endpoints = 1, + .endpoints = &single_endpoint, + .name_prefix = "rt715" + } +}; + +static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = { + { + .adr = 0x000030025d071101, + .num_endpoints = 1, + .endpoints = &single_endpoint, + .name_prefix = "rt711" + } +}; + +static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = { + { + .adr = 0x000131025d131601, /* unique id is set for some reason */ + .num_endpoints = 1, + .endpoints = &spk_l_endpoint, + .name_prefix = "rt1316-1" + } +}; + +static const struct snd_soc_acpi_adr_device rt1316_2_group1_adr[] = { + { + .adr = 0x000230025d131601, + .num_endpoints = 1, + .endpoints = &spk_r_endpoint, + .name_prefix = "rt1316-2" + } +}; + +static const struct snd_soc_acpi_adr_device rt1316_3_group1_adr[] = { + { + .adr = 0x000330025d131601, + .num_endpoints = 1, + .endpoints = &spk_r_endpoint, + .name_prefix = "rt1316-2" + } +}; + +static const struct snd_soc_acpi_adr_device rt714_2_adr[] = { + { + .adr = 0x000230025d071401, + .num_endpoints = 1, + .endpoints = &single_endpoint, + .name_prefix = "rt714" + } +}; + +static const struct snd_soc_acpi_adr_device rt714_3_adr[] = { + { + .adr = 0x000330025d071401, + .num_endpoints = 1, + .endpoints = &single_endpoint, + .name_prefix = "rt714" + } +}; + +static const struct snd_soc_acpi_link_adr adl_default[] = { + { + .mask = bit(0), + .num_adr = array_size(rt711_0_adr), + .adr_d = rt711_0_adr, + }, + { + .mask = bit(1), + .num_adr = array_size(rt1308_1_group1_adr), + .adr_d = rt1308_1_group1_adr, + }, + { + .mask = bit(2), + .num_adr = array_size(rt1308_2_group1_adr), + .adr_d = rt1308_2_group1_adr, + }, + { + .mask = bit(3), + .num_adr = array_size(rt715_3_adr), + .adr_d = rt715_3_adr, + }, + {} +}; + +static const struct snd_soc_acpi_link_adr adl_sdca_default[] = { + { + .mask = bit(0), + .num_adr = array_size(rt711_sdca_0_adr), + .adr_d = rt711_sdca_0_adr, + }, + { + .mask = bit(1), + .num_adr = array_size(rt1316_1_group1_adr), + .adr_d = rt1316_1_group1_adr, + }, + { + .mask = bit(2), + .num_adr = array_size(rt1316_2_group1_adr), + .adr_d = rt1316_2_group1_adr, + }, + { + .mask = bit(3), + .num_adr = array_size(rt714_3_adr), + .adr_d = rt714_3_adr, + }, + {} +}; + +static const struct snd_soc_acpi_link_adr adl_sdca_3_in_1[] = { + { + .mask = bit(0), + .num_adr = array_size(rt711_sdca_0_adr), + .adr_d = rt711_sdca_0_adr, + }, + { + .mask = bit(1), + .num_adr = array_size(rt1316_1_group1_adr), + .adr_d = rt1316_1_group1_adr, + }, + { + .mask = bit(2), + .num_adr = array_size(rt714_2_adr), + .adr_d = rt714_2_adr, + }, + { + .mask = bit(3), + .num_adr = array_size(rt1316_3_group1_adr), + .adr_d = rt1316_3_group1_adr, + }, + {} +}; + + { + .link_mask = 0xf, /* 4 active links required */ + .links = adl_default, + .drv_name = "sof_sdw", + .sof_tplg_filename = "sof-adl-rt711-l0-rt1308-l12-rt715-l3.tplg", + }, + { + .link_mask = 0xf, /* 4 active links required */ + .links = adl_sdca_default, + .drv_name = "sof_sdw", + .sof_tplg_filename = "sof-adl-rt711-l0-rt1316-l12-rt714-l3.tplg", + }, + { + .link_mask = 0xf, /* 4 active links required */ + .links = adl_sdca_3_in_1, + .drv_name = "sof_sdw", + .sof_tplg_filename = "sof-adl-rt711-l0-rt1316-l13-rt714-l2.tplg", + },
|
Audio
|
093b9dcb597611ce65f8c5610ee446616c0be304
|
pierre louis bossart
|
sound
|
soc
|
common, intel
|
asoc: intel: soc-acpi: add adl jack-less soundwire configurations
|
add one configuration with no rt711.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add adl jack-less soundwire configurations
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'intel', 'soc-acpi']
|
['c']
| 1
| 38
| 0
|
--- diff --git a/sound/soc/intel/common/soc-acpi-intel-adl-match.c b/sound/soc/intel/common/soc-acpi-intel-adl-match.c --- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c +static const struct snd_soc_acpi_adr_device rt1316_2_single_adr[] = { + { + .adr = 0x000230025d131601, + .num_endpoints = 1, + .endpoints = &single_endpoint, + .name_prefix = "rt1316-1" + } +}; + +static const struct snd_soc_acpi_adr_device rt714_0_adr[] = { + { + .adr = 0x000030025d071401, + .num_endpoints = 1, + .endpoints = &single_endpoint, + .name_prefix = "rt714" + } +}; + +static const struct snd_soc_acpi_link_adr adl_sdw_rt1316_link2_rt714_link0[] = { + { + .mask = bit(2), + .num_adr = array_size(rt1316_2_single_adr), + .adr_d = rt1316_2_single_adr, + }, + { + .mask = bit(0), + .num_adr = array_size(rt714_0_adr), + .adr_d = rt714_0_adr, + }, + {} +}; + + { + .link_mask = 0x5, /* 2 active links required */ + .links = adl_sdw_rt1316_link2_rt714_link0, + .drv_name = "sof_sdw", + .sof_tplg_filename = "sof-adl-rt1316-l2-mono-rt714-l0.tplg", + },
|
Audio
|
870dc42fe8311ef5b291ccb21eda3f7069b6f599
|
pierre louis bossart rander wang rander wang intel com libin yang libin yang intel com
|
sound
|
soc
|
common, intel
|
asoc: intel: sof_rt5682: add alc1015q-vb speaker amp support
|
this patch adds jsl_rt5682_rt1015p which supports the rt5682 headset codec and alc1015q-vb speaker amplifier combination on jasperlake platform.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add alc1015q-vb speaker amp support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'intel', 'sof_rt5682']
|
['h', 'kconfig', 'c']
| 5
| 143
| 2
|
--- diff --git a/sound/soc/intel/boards/kconfig b/sound/soc/intel/boards/kconfig --- a/sound/soc/intel/boards/kconfig +++ b/sound/soc/intel/boards/kconfig + select snd_soc_rt1015p diff --git a/sound/soc/intel/boards/sof_realtek_common.c b/sound/soc/intel/boards/sof_realtek_common.c --- a/sound/soc/intel/boards/sof_realtek_common.c +++ b/sound/soc/intel/boards/sof_realtek_common.c +#include <sound/soc-acpi.h> + +/* + * rt1015: i2c mode driver for alc1015 and alc1015q + * rt1015p: auto-mode driver for alc1015, alc1015q, and alc1015q-vb + * + * for stereo output, there are always two amplifiers on the board. + * however, the acpi implements only one device instance (uid=0) if they + * are sharing the same enable pin. the code will detect the number of + * device instance and use corresponding dapm structures for + * initialization. + */ +static const struct snd_soc_dapm_route rt1015p_1dev_dapm_routes[] = { + /* speaker */ + { "left spk", null, "speaker" }, + { "right spk", null, "speaker" }, +}; + +static const struct snd_soc_dapm_route rt1015p_2dev_dapm_routes[] = { + /* speaker */ + { "left spk", null, "left speaker" }, + { "right spk", null, "right speaker" }, +}; + +static struct snd_soc_codec_conf rt1015p_codec_confs[] = { + { + .dlc = comp_codec_conf(rt1015p_dev0_name), + .name_prefix = "left", + }, + { + .dlc = comp_codec_conf(rt1015p_dev1_name), + .name_prefix = "right", + }, +}; + +static struct snd_soc_dai_link_component rt1015p_dai_link_components[] = { + { + .name = rt1015p_dev0_name, + .dai_name = rt1015p_codec_dai, + }, + { + .name = rt1015p_dev1_name, + .dai_name = rt1015p_codec_dai, + }, +}; + +static int rt1015p_get_num_codecs(void) +{ + static int dev_num; + + if (dev_num) + return dev_num; + + if (!acpi_dev_present("rtl1015", "1", -1)) + dev_num = 1; + else + dev_num = 2; + + return dev_num; +} + +static int rt1015p_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + /* reserved for debugging purpose */ + + return 0; +} + +static const struct snd_soc_ops rt1015p_ops = { + .hw_params = rt1015p_hw_params, +}; + +static int rt1015p_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_card *card = rtd->card; + int ret; + + if (rt1015p_get_num_codecs() == 1) + ret = snd_soc_dapm_add_routes(&card->dapm, rt1015p_1dev_dapm_routes, + array_size(rt1015p_1dev_dapm_routes)); + else + ret = snd_soc_dapm_add_routes(&card->dapm, rt1015p_2dev_dapm_routes, + array_size(rt1015p_2dev_dapm_routes)); + if (ret) + dev_err(rtd->dev, "speaker map addition failed: %d ", ret); + return ret; +} + +void sof_rt1015p_dai_link(struct snd_soc_dai_link *link) +{ + link->codecs = rt1015p_dai_link_components; + link->num_codecs = rt1015p_get_num_codecs(); + link->init = rt1015p_init; + link->ops = &rt1015p_ops; +} + +void sof_rt1015p_codec_conf(struct snd_soc_card *card) +{ + if (rt1015p_get_num_codecs() == 1) + return; + + card->codec_conf = rt1015p_codec_confs; + card->num_configs = array_size(rt1015p_codec_confs); +} diff --git a/sound/soc/intel/boards/sof_realtek_common.h b/sound/soc/intel/boards/sof_realtek_common.h --- a/sound/soc/intel/boards/sof_realtek_common.h +++ b/sound/soc/intel/boards/sof_realtek_common.h +#define rt1015p_codec_dai "hifi" +#define rt1015p_dev0_name "rtl1015:00" +#define rt1015p_dev1_name "rtl1015:01" + +void sof_rt1015p_dai_link(struct snd_soc_dai_link *link); +void sof_rt1015p_codec_conf(struct snd_soc_card *card); + diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c -#define sof_max98373_speaker_amp_present bit(16) -#define sof_max98360a_speaker_amp_present bit(17) +#define sof_rt1015p_speaker_amp_present bit(16) +#define sof_max98373_speaker_amp_present bit(17) +#define sof_max98360a_speaker_amp_present bit(18) + } else if (sof_rt5682_quirk & sof_rt1015p_speaker_amp_present) { + sof_rt1015p_dai_link(&links[id]); + else if (sof_rt5682_quirk & sof_rt1015p_speaker_amp_present) + sof_rt1015p_codec_conf(&sof_audio_card_rt5682); + { + .name = "jsl_rt5682_rt1015p", + .driver_data = (kernel_ulong_t)(sof_rt5682_mclk_en | + sof_rt5682_mclk_24mhz | + sof_rt5682_ssp_codec(0) | + sof_speaker_amp_present | + sof_rt1015p_speaker_amp_present | + sof_rt5682_ssp_amp(1)), + }, +module_alias("platform:jsl_rt5682_rt1015p"); diff --git a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c --- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c +static struct snd_soc_acpi_codecs rt1015p_spk = { + .num_codecs = 1, + .codecs = {"rtl1015"} +}; + + { + .id = "10ec5682", + .drv_name = "jsl_rt5682_rt1015p", + .sof_fw_filename = "sof-jsl.ri", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &rt1015p_spk, + .sof_tplg_filename = "sof-jsl-rt5682-rt1015.tplg", + },
|
Audio
|
ad83b1adc58d6693036fd330d6af95a33564eaae
|
brent lu
|
sound
|
soc
|
boards, common, intel
|
asoc: ak5558: add support for ak5552
|
ak5552 is a 32-bit 2ch adc and has the same register map as ak5558.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for ak5552
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'ak5558']
|
['c']
| 1
| 90
| 7
|
--- diff --git a/sound/soc/codecs/ak5558.c b/sound/soc/codecs/ak5558.c --- a/sound/soc/codecs/ak5558.c +++ b/sound/soc/codecs/ak5558.c +#include <linux/of_device.h> +enum ak555x_type { + ak5558, + ak5552, +}; + +static const char * const mono_5552_texts[] = { + "2 slot", "1 slot (fixed)", "2 slot", "1 slot (optimal)", +}; + +static const struct soc_enum ak5552_mono_enum[] = { + soc_enum_single(ak5558_01_power_management2, 1, + array_size(mono_5552_texts), mono_5552_texts), +}; + - soc_enum("ak5558 monaural mode", ak5558_mono_enum[0]), - soc_enum("ak5558 digital filter", ak5558_adcset_enum[0]), + soc_enum("monaural mode", ak5558_mono_enum[0]), + soc_enum("digital filter", ak5558_adcset_enum[0]), +}; + +static const struct snd_kcontrol_new ak5552_snd_controls[] = { + soc_enum("monaural mode", ak5552_mono_enum[0]), + soc_enum("digital filter", ak5558_adcset_enum[0]), +static const struct snd_soc_dapm_widget ak5552_dapm_widgets[] = { + /* analog input */ + snd_soc_dapm_input("ain1"), + snd_soc_dapm_input("ain2"), + + snd_soc_dapm_adc("adc ch1", null, ak5558_00_power_management1, 0, 0), + snd_soc_dapm_adc("adc ch2", null, ak5558_00_power_management1, 1, 0), + + snd_soc_dapm_aif_out("sdto", "capture", 0, snd_soc_nopm, 0, 0), +}; + +static const struct snd_soc_dapm_route ak5552_intercon[] = { + {"adc ch1", null, "ain1"}, + {"sdto", null, "adc ch1"}, + + {"adc ch2", null, "ain2"}, + {"sdto", null, "adc ch2"}, +}; + +static struct snd_soc_dai_driver ak5552_dai = { + .name = "ak5558-aif", + .capture = { + .stream_name = "capture", + .channels_min = 1, + .channels_max = 2, + .rates = sndrv_pcm_rate_knot, + .formats = ak5558_formats, + }, + .ops = &ak5558_dai_ops, +}; + +static const struct snd_soc_component_driver soc_codec_dev_ak5552 = { + .probe = ak5558_probe, + .remove = ak5558_remove, + .controls = ak5552_snd_controls, + .num_controls = array_size(ak5552_snd_controls), + .dapm_widgets = ak5552_dapm_widgets, + .num_dapm_widgets = array_size(ak5552_dapm_widgets), + .dapm_routes = ak5552_intercon, + .num_dapm_routes = array_size(ak5552_intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; + + int dev_id; - ret = devm_snd_soc_register_component(&i2c->dev, - &soc_codec_dev_ak5558, - &ak5558_dai, 1); - if (ret) + dev_id = (uintptr_t)of_device_get_match_data(&i2c->dev); + switch (dev_id) { + case ak5552: + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_codec_dev_ak5552, + &ak5552_dai, 1); + break; + case ak5558: + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_codec_dev_ak5558, + &ak5558_dai, 1); + break; + default: + dev_err(&i2c->dev, "unexpected device type "); + return -einval; + } + if (ret < 0) { + dev_err(&i2c->dev, "failed to register component: %d ", ret); + } - { .compatible = "asahi-kasei,ak5558"}, + { .compatible = "asahi-kasei,ak5558", .data = (void *) ak5558 }, + { .compatible = "asahi-kasei,ak5552", .data = (void *) ak5552 },
|
Audio
|
d8c5c82e4e5b641404c65bfc6cdf57b5d0a6c836
|
viorel suman
|
sound
|
soc
|
codecs
|
asoc: amd: add support for alc1015p codec in acp3x machine driver
|
add alc1015p codec support for acp3x machine driver.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for alc1015p codec in acp3x machine driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'amd']
|
['kconfig', 'c']
| 2
| 46
| 1
|
--- diff --git a/sound/soc/amd/kconfig b/sound/soc/amd/kconfig --- a/sound/soc/amd/kconfig +++ b/sound/soc/amd/kconfig + select snd_soc_rt1015p diff --git a/sound/soc/amd/acp3x-rt5682-max9836.c b/sound/soc/amd/acp3x-rt5682-max9836.c --- a/sound/soc/amd/acp3x-rt5682-max9836.c +++ b/sound/soc/amd/acp3x-rt5682-max9836.c +snd_soc_dailink_def(rt1015p, + dailink_comp_array(comp_codec("rtl1015:00", "hifi"))); +static const struct snd_soc_dapm_widget acp3x_1015p_widgets[] = { + snd_soc_dapm_hp("headphone jack", null), + snd_soc_dapm_mic("headset mic", null), + snd_soc_dapm_mux("dmic mux", snd_soc_nopm, 0, 0, + &acp3x_dmic_mux_control), + snd_soc_dapm_spk("speakers", null), +}; + +static const struct snd_soc_dapm_route acp3x_1015p_route[] = { + {"headphone jack", null, "hpol"}, + {"headphone jack", null, "hpor"}, + {"in1p", null, "headset mic"}, + {"dmic mux", "front mic", "dmic"}, + {"dmic mux", "rear mic", "dmic"}, + /* speaker */ + { "speakers", null, "speaker" }, +}; + +static const struct snd_kcontrol_new acp3x_mc_1015p_controls[] = { + soc_dapm_pin_switch("speakers"), + soc_dapm_pin_switch("headphone jack"), + soc_dapm_pin_switch("headset mic"), +}; + +static struct snd_soc_card acp3x_1015p = { + .name = "acp3xalc56821015p", + .owner = this_module, + .dai_link = acp3x_dai, + .num_links = array_size(acp3x_dai), + .dapm_widgets = acp3x_1015p_widgets, + .num_dapm_widgets = array_size(acp3x_1015p_widgets), + .dapm_routes = acp3x_1015p_route, + .num_dapm_routes = array_size(acp3x_1015p_route), + .controls = acp3x_mc_1015p_controls, + .num_controls = array_size(acp3x_mc_1015p_controls), +}; + + } else if (!strcmp(card_name, "acp3xalc56821015p")) { + links[1].codecs = rt1015p; + links[1].num_codecs = array_size(rt1015p); + { "10021015", (unsigned long)&acp3x_1015p}, -module_description("alc5682 alc1015 & max98357 audio support"); +module_author("vijendar.mukunda@amd.com"); +module_description("alc5682 alc1015, alc1015p & max98357 audio support");
|
Audio
|
26e33ed9f18475ebdc981d45150ac9a019e69f07
|
vijendar mukunda
|
sound
|
soc
|
amd
|
asoc: amd: add support for rt5682 codec in machine driver
|
add support for rt5682 codec in machine driver.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
add support for rt5682 codec in machine driver
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'amd']
|
['kconfig', 'c']
| 2
| 345
| 17
|
--- diff --git a/sound/soc/amd/kconfig b/sound/soc/amd/kconfig --- a/sound/soc/amd/kconfig +++ b/sound/soc/amd/kconfig - tristate "amd cz support for da7219 and max9835" + tristate "amd cz support for da7219, rt5682 and max9835" + select snd_soc_rt5682_i2c - this option enables machine driver for da7219 and max9835. + this option enables machine driver for da7219, rt5682 and max9835. diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c --- a/sound/soc/amd/acp-da7219-max98357a.c +++ b/sound/soc/amd/acp-da7219-max98357a.c +#include "../codecs/rt5682.h" +#define rt5682_pll_freq (48000 * 512) +static struct clk *rt5682_dai_wclk; +static struct clk *rt5682_dai_bclk; +void *acp_soc_is_rltk_max(struct device *dev); +static int cz_rt5682_init(struct snd_soc_pcm_runtime *rtd) +{ + int ret; + struct snd_soc_card *card = rtd->card; + struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); + struct snd_soc_component *component = codec_dai->component; + + dev_info(codec_dai->dev, "codec dai name = %s ", codec_dai->name); + + /* set codec sysclk */ + ret = snd_soc_dai_set_sysclk(codec_dai, rt5682_sclk_s_pll2, + rt5682_pll_freq, snd_soc_clock_in); + if (ret < 0) { + dev_err(codec_dai->dev, + "failed to set rt5682 sysclk: %d ", ret); + return ret; + } + /* set codec pll */ + ret = snd_soc_dai_set_pll(codec_dai, rt5682_pll2, rt5682_pll2_s_mclk, + cz_plat_clk, rt5682_pll_freq); + if (ret < 0) { + dev_err(codec_dai->dev, "can't set rt5682 pll: %d ", ret); + return ret; + } + + rt5682_dai_wclk = devm_clk_get(component->dev, "rt5682-dai-wclk"); + if (is_err(rt5682_dai_wclk)) + return ptr_err(rt5682_dai_wclk); + + rt5682_dai_bclk = devm_clk_get(component->dev, "rt5682-dai-bclk"); + if (is_err(rt5682_dai_bclk)) + return ptr_err(rt5682_dai_bclk); + + ret = snd_soc_card_jack_new(card, "headset jack", + snd_jack_headset | snd_jack_lineout | + snd_jack_btn_0 | snd_jack_btn_1 | + snd_jack_btn_2 | snd_jack_btn_3, + &cz_jack, null, 0); + if (ret) { + dev_err(card->dev, "hp jack creation failed %d ", ret); + return ret; + } + + snd_jack_set_key(cz_jack.jack, snd_jack_btn_0, key_playpause); + snd_jack_set_key(cz_jack.jack, snd_jack_btn_1, key_volumeup); + snd_jack_set_key(cz_jack.jack, snd_jack_btn_2, key_volumedown); + snd_jack_set_key(cz_jack.jack, snd_jack_btn_3, key_voicecommand); + + ret = snd_soc_component_set_jack(component, &cz_jack, null); + if (ret) { + dev_err(rtd->dev, "headset jack call-back failed: %d ", ret); + return ret; + } + return 0; +} + +static int rt5682_clk_enable(struct snd_pcm_substream *substream) +{ + int ret; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + + /* + * set wclk to 48000 because the rate constraint of this driver is + * 48000. adau7002 spec: "the adau7002 requires a bclk rate that is + * minimum of 64x the lrclk sample rate." rt5682 is the only clk + * source so for all codecs we have to limit bclk to 64x lrclk. + */ + ret = clk_set_rate(rt5682_dai_wclk, 48000); + if (ret) { + dev_err(rtd->dev, "error setting wclk rate: %d ", ret); + return ret; + } + ret = clk_set_rate(rt5682_dai_bclk, 48000 * 64); + if (ret) { + dev_err(rtd->dev, "error setting bclk rate: %d ", ret); + return ret; + } + ret = clk_prepare_enable(rt5682_dai_wclk); + if (ret < 0) { + dev_err(rtd->dev, "can't enable wclk %d ", ret); + return ret; + } + return ret; +} + +static void rt5682_clk_disable(void) +{ + clk_disable_unprepare(rt5682_dai_wclk); +} + +static int cz_rt5682_play_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_card *card = rtd->card; + struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); + + /* + * on this platform for pcm device we support stereo + */ + + runtime->hw.channels_max = dual_channel; + snd_pcm_hw_constraint_list(runtime, 0, sndrv_pcm_hw_param_channels, + &constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, sndrv_pcm_hw_param_rate, + &constraints_rates); + + machine->play_i2s_instance = i2s_sp_instance; + return rt5682_clk_enable(substream); +} + +static int cz_rt5682_cap_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_card *card = rtd->card; + struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); + + /* + * on this platform for pcm device we support stereo + */ + + runtime->hw.channels_max = dual_channel; + snd_pcm_hw_constraint_list(runtime, 0, sndrv_pcm_hw_param_channels, + &constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, sndrv_pcm_hw_param_rate, + &constraints_rates); + + machine->cap_i2s_instance = i2s_sp_instance; + machine->capture_channel = cap_channel1; + return rt5682_clk_enable(substream); +} + +static int cz_rt5682_max_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_card *card = rtd->card; + struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); + + /* + * on this platform for pcm device we support stereo + */ + + runtime->hw.channels_max = dual_channel; + snd_pcm_hw_constraint_list(runtime, 0, sndrv_pcm_hw_param_channels, + &constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, sndrv_pcm_hw_param_rate, + &constraints_rates); + + machine->play_i2s_instance = i2s_bt_instance; + return rt5682_clk_enable(substream); +} + +static int cz_rt5682_dmic0_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_card *card = rtd->card; + struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); + + /* + * on this platform for pcm device we support stereo + */ + + runtime->hw.channels_max = dual_channel; + snd_pcm_hw_constraint_list(runtime, 0, sndrv_pcm_hw_param_channels, + &constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, sndrv_pcm_hw_param_rate, + &constraints_rates); + + machine->cap_i2s_instance = i2s_bt_instance; + return rt5682_clk_enable(substream); +} + +static int cz_rt5682_dmic1_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + struct snd_soc_card *card = rtd->card; + struct acp_platform_info *machine = snd_soc_card_get_drvdata(card); + + /* + * on this platform for pcm device we support stereo + */ + + runtime->hw.channels_max = dual_channel; + snd_pcm_hw_constraint_list(runtime, 0, sndrv_pcm_hw_param_channels, + &constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, sndrv_pcm_hw_param_rate, + &constraints_rates); + + machine->cap_i2s_instance = i2s_sp_instance; + machine->capture_channel = cap_channel0; + return rt5682_clk_enable(substream); +} + +static void cz_rt5682_shutdown(struct snd_pcm_substream *substream) +{ + rt5682_clk_disable(); +} + +static const struct snd_soc_ops cz_rt5682_play_ops = { + .startup = cz_rt5682_play_startup, + .shutdown = cz_rt5682_shutdown, +}; + +static const struct snd_soc_ops cz_rt5682_cap_ops = { + .startup = cz_rt5682_cap_startup, + .shutdown = cz_rt5682_shutdown, +}; + +static const struct snd_soc_ops cz_rt5682_max_play_ops = { + .startup = cz_rt5682_max_startup, + .shutdown = cz_rt5682_shutdown, +}; + +static const struct snd_soc_ops cz_rt5682_dmic0_cap_ops = { + .startup = cz_rt5682_dmic0_startup, + .shutdown = cz_rt5682_shutdown, +}; + +static const struct snd_soc_ops cz_rt5682_dmic1_cap_ops = { + .startup = cz_rt5682_dmic1_startup, + .shutdown = cz_rt5682_shutdown, +}; + +snd_soc_dailink_def(rt5682, + dailink_comp_array(comp_codec("i2c-10ec5682:00", "rt5682-aif1"))); +static struct snd_soc_dai_link cz_dai_5682_98357[] = { + { + .name = "amd-rt5682-play", + .stream_name = "playback", + .dai_fmt = snd_soc_daifmt_i2s | snd_soc_daifmt_nb_nf + | snd_soc_daifmt_cbm_cfm, + .init = cz_rt5682_init, + .dpcm_playback = 1, + .ops = &cz_rt5682_play_ops, + snd_soc_dailink_reg(designware1, rt5682, platform), + }, + { + .name = "amd-rt5682-cap", + .stream_name = "capture", + .dai_fmt = snd_soc_daifmt_i2s | snd_soc_daifmt_nb_nf + | snd_soc_daifmt_cbm_cfm, + .dpcm_capture = 1, + .ops = &cz_rt5682_cap_ops, + snd_soc_dailink_reg(designware2, rt5682, platform), + }, + { + .name = "amd-max98357-play", + .stream_name = "hifi playback", + .dai_fmt = snd_soc_daifmt_i2s | snd_soc_daifmt_nb_nf + | snd_soc_daifmt_cbm_cfm, + .dpcm_playback = 1, + .ops = &cz_rt5682_max_play_ops, + snd_soc_dailink_reg(designware3, mx, platform), + }, + { + /* c panel dmic */ + .name = "dmic0", + .stream_name = "dmic0 capture", + .dai_fmt = snd_soc_daifmt_i2s | snd_soc_daifmt_nb_nf + | snd_soc_daifmt_cbm_cfm, + .dpcm_capture = 1, + .ops = &cz_rt5682_dmic0_cap_ops, + snd_soc_dailink_reg(designware3, adau, platform), + }, + { + /* a/b panel dmic */ + .name = "dmic1", + .stream_name = "dmic1 capture", + .dai_fmt = snd_soc_daifmt_i2s | snd_soc_daifmt_nb_nf + | snd_soc_daifmt_cbm_cfm, + .dpcm_capture = 1, + .ops = &cz_rt5682_dmic1_cap_ops, + snd_soc_dailink_reg(designware2, adau, platform), + }, +}; + +static const struct snd_soc_dapm_route cz_rt5682_audio_route[] = { + {"headphones", null, "hpol"}, + {"headphones", null, "hpor"}, + {"in1p", null, "headset mic"}, + {"speakers", null, "speaker"}, + {"pdm_dat", null, "int mic"}, +}; + +static struct snd_soc_card cz_rt5682_card = { + .name = "acpr5682m98357", + .owner = this_module, + .dai_link = cz_dai_5682_98357, + .num_links = array_size(cz_dai_5682_98357), + .dapm_widgets = cz_widgets, + .num_dapm_widgets = array_size(cz_widgets), + .dapm_routes = cz_rt5682_audio_route, + .controls = cz_mc_controls, + .num_controls = array_size(cz_mc_controls), +}; + +void *acp_soc_is_rltk_max(struct device *dev) +{ + const struct acpi_device_id *match; + + match = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!match) + return null; + return (void *)match->driver_data; +} + - - acp_da7219_cfg.dev = &pdev->dev; - rdev = devm_regulator_register(&pdev->dev, &acp_da7219_desc, - &acp_da7219_cfg); - if (is_err(rdev)) { - dev_err(&pdev->dev, "failed to register regulator: %d ", - (int)ptr_err(rdev)); - return -einval; + struct device *dev = &pdev->dev; + + card = (struct snd_soc_card *)acp_soc_is_rltk_max(dev); + if (!card) + return -enodev; + if (!strcmp(card->name, "acpd7219m98357")) { + acp_da7219_cfg.dev = &pdev->dev; + rdev = devm_regulator_register(&pdev->dev, &acp_da7219_desc, + &acp_da7219_cfg); + if (is_err(rdev)) { + dev_err(&pdev->dev, "failed to register regulator: %d ", + (int)ptr_err(rdev)); + return -einval; + } - card = &cz_card; - cz_card.dev = &pdev->dev; + card->dev = &pdev->dev; - ret = devm_snd_soc_register_card(&pdev->dev, &cz_card); + ret = devm_snd_soc_register_card(&pdev->dev, card); - dev_err(&pdev->dev, + if (ret != -eprobe_defer) + dev_err(&pdev->dev, - cz_card.name, ret); + card->name, ret); + else + dev_dbg(&pdev->dev, + "devm_snd_soc_register_card(%s) probe deferred: %d ", + card->name, ret); - { "amd7219", 0 }, + { "amd7219", (unsigned long)&cz_card }, + { "amdi5682", (unsigned long)&cz_rt5682_card}, -module_description("da7219 & max98357a audio support"); +module_author("vijendar.mukunda@amd.com"); +module_description("da7219, rt5682 & max98357a audio support");
|
Audio
|
7e71b48f9e27e437ca523432ea285c2585a539dc
|
vijendar mukunda
|
sound
|
soc
|
amd
|
asoc: codecs: tlv320aic3x: move model definitions
|
model definitions moved to header file. preparation for spi and i2c separated files.
|
this release includes the landlock security module, which aims to make easier to sandbox applications; support for the clang control flow integrity, which aims to abort the program upon detecting certain forms of undefined behavior; support for randomising the stack address offset in each syscall; support for concurrent tbl flushing; preparatory apple m1 support; support for incoming amd and intel graphics chips; bpf support for calling kernel functions directly; a virtio sound driver for improved sound experience on virtualized guests; io_uring support for multi shot mode and a misc cgroup for miscellaneous resources. as always, there are many other features, new drivers, improvements and fixes.
|
tlv320aic3x add spi support
|
['core (various)', 'file systems', 'memory management', 'block layer', 'tracing, perf and bpf', 'virtualization', 'security', 'networking', 'architectures arm x86 mips powerpc riscv s390 ia64 xtensa']
|
['graphics', 'power management', 'storage', 'drivers in the staging area', 'networking', 'audio', 'tablets, touch screens, keyboards, mouses', 'tv tuners, webcams, video capturers', 'universal serial bus', 'serial peripheral interface (spi)', 'watchdog', 'serial', 'cpu frequency scaling', 'voltage, current regulators, power capping, power supply', 'real time clock (rtc)', 'pin controllers (pinctrl)', 'multi media card (mmc)', 'memory technology devices (mtd)', 'industrial i/o (iio)', 'multi function devices (mfd)', 'pulse-width modulation (pwm)', 'inter-integrated circuit (i2c + i3c)', 'hardware monitoring (hwmon)', 'general purpose i/o (gpio)', 'leds', 'dma engines', 'cryptography hardware acceleration', 'pci', 'remote processors', 'clock', 'phy ("physical layer" framework)', 'various']
|
['asoc ', 'soc codecs']
|
['h', 'c']
| 2
| 5
| 4
|
--- diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c -#define aic3x_model_3x 0 -#define aic3x_model_33 1 -#define aic3x_model_3007 2 -#define aic3x_model_3104 3 diff --git a/sound/soc/codecs/tlv320aic3x.h b/sound/soc/codecs/tlv320aic3x.h --- a/sound/soc/codecs/tlv320aic3x.h +++ b/sound/soc/codecs/tlv320aic3x.h +#define aic3x_model_3x 0 +#define aic3x_model_33 1 +#define aic3x_model_3007 2 +#define aic3x_model_3104 3 +
|
Audio
|
73a4808892b83c8336c3d913d44b8de68d881369
|
jiri prchal
|
sound
|
soc
|
codecs
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.