Skip to contentSkip to conversation

Add tas2781 driver for SPI.

PATCH Superseded Baojun Xu 2 participants 4 messages May 19, 2024

Subsystems (4)

v5 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Baojun Xu

author
#0 lore raw

v5 cover Add tas2781 driver for SPI.

This patch was used to add TAS2781 devices on SPI support in sound/pci/hda. It use ACPI node descript about parameters of TAS2781 on SPI, it like:

    Scope (_SB.PC00.SPI0)
    {
        Device (GSPK)
        {
            Name (_HID, "TXNW2781")  // _HID: Hardware ID
            Method (_CRS, 0, NotSerialized)
            {
                Name (RBUF, ResourceTemplate ()
                {
                    SpiSerialBusV2 (...)
                    SpiSerialBusV2 (...)
                }
            }
        }
    }

And in platform/x86/serial-multi-instantiate.c, those spi devices will be added into system as a single SPI device, so TAS2781 SPI driver will probe twice for every single SPI device. And driver will also parser mono DSP firmware binary and RCA binary for itself.

Baojun Xu (1):
ALSA: hda/tas2781: Add tas2781 hda driver based on SPI

 drivers/acpi/scan.c                           |    1 +
 .../platform/x86/serial-multi-instantiate.c   |   12 +
 sound/pci/hda/Kconfig                         |   14 +
 sound/pci/hda/Makefile                        |    2 +
 sound/pci/hda/patch_realtek.c                 |   13 +
 sound/pci/hda/tas2781-spi.h                   |  148 ++
 sound/pci/hda/tas2781_hda_spi.c               | 1234 +++++++++
 sound/pci/hda/tas2781_spi_fwlib.c             | 2247 +++++++++++++++++
 8 files changed, 3671 insertions(+)
 create mode 100644 sound/pci/hda/tas2781-spi.h
 create mode 100644 sound/pci/hda/tas2781_hda_spi.c
 create mode 100644 sound/pci/hda/tas2781_spi_fwlib.c
Signature · 1 line
2.40.1
author
#1 lore raw

PATCH v5 1/1 ALSA: hda/tas2781: Add tas2781 hda driver based on SPI

Integrate tas2781 hda spi driver configs for HP (Varcolac). Every tas2781 SPI node was added by serial-multi-instantie.c as a single SPI device. The code support Realtek as the primary codec.

---
v5:
- Combined all modification into one patch for pass the compile.
- Remove old hardware id "TIAS2781" as no production on market.
- Change max page size to 256 in tas2781-spi.h.
- Change book reg from 127 to GENMASK(7, 1), as one bit shift is needed.
- Change register address define as one bit shift needed for offset.
- Change block check sum comments to Firmware block from I2C.
- Change define of (page + reg) to TASDEVICE_PAGE_REG from TASDEVICE_PGRG.
- Change to lower case in defined value.
- Add registers default value table in tas2781_hda_spi.c
- Change rang_max to 256 * 256.
- Add zero_flag_mask in regmap_config.
- Change max_register to 256 * 256.
- Add registers default table into structure regmap_config.
- Change parameter from book number to whole register address.
- Remove page 0 switch as SPI driver will do it.
- Add bit(0) for read function as tas2781 will check last bit of address, to determine operation mode is read (1) or write (0).
- Change switch case to if check in tas2781_hda_playback_hook(), as it may cause compile problem in clang-19 building.
- Change variable declaration position.
- Change order in if check.
- Remove old hardware id ("TIAS2781") support.
- Remove debug message in runtime suspend and resume.
- Remove regmap.h include in tas2781_spi_fwlib.c.
- Remove MODULE_ in fwlib as this file will work with tas2781_hda_spi.c only.
v4:
- Add old hardware id "TIAS2781" for compatible with old production
- Add 2 devices in struct smi_node tas2781_hda, to compatible with 4 AMPs
v4:
- Add old hardware id "TIAS2781" for compatible with old production
- Add 2 devices in struct smi_node tas2781_hda, to compatible with 4 AMPs
- Move include of sound/tas2781-dsp.h to c source file tas2781_hda_spi.c, tas2781_spi_fwlib.c, as it's not needed in header file tas2781-spi.h
- Use page and book number define in other micro define
- Change 4000000 to (4 * HZ_PER_MHZ)
- Add define for calibration variable name and size in UEFI.
- Remove structure tasdevice & tasdevice_irqinfo, and move variables in to structure tasdevice_priv
- Remove some unused variables in sttructure tasdevice_priv
- Remove function declare of tascodec_init(), use tascodec_spi_init()
- Remove function declare of tasdevice_remove()
- Add array_size.h included in tas2781_hda_spi.c
- Add cleanup.h included for change mutex to guard
- Add units.h included
- Include tas2781-dsp.h
- Remove unused variables in tas2781_hda structure
- Change 0xff to GENMASK(7, 0)
- Change 128 to define of max page size
- Change code as all variables was moved to tasdevice_priv structure
- Change comments for error in book write, or page write
- Remove initial of ret, and return 0 directly
- Change comments for wrong typo, add space in front and end
- Add check for bulk read, max size should be a page size
- Change usleep_rang() to fsleep()
- Change mutex_lock to guard(mutex), and remove mutex_unlock()
- Change tasdevice_spi_init() to void from int as no value return required
- Change second parameter to sizeof
- Remove tasdevice_clamp(), use clamp()
- Add compatible with old hardware id "TIAS2781"
- Remove cs_gpio and spi device in tas2781_read_acpi() as use default CS
- Change dev-index check, return -EINVAL if it's <= 0
- Change 0xFF to U8_MAX
- Remove GPIO get for chip-select, use default from SPI device
- Perform RESET in first AMP only as all AMPs share same RESET pin
- return 0 directly in some simple routine to avoid variable initial
- Change comments for function which was used by system
- Change "ON" "OFF" to function str_on_off(...)
- Change format of GUID
- Add temp buffer for first efi.get_variable()
- Free data if it was allocated
- Change format of debug message of calibration date time print
- Remove total_sz = 0, as it's not needed
- Move save_calibration to after tuning_switch to avoid calibration data overwrite
- Remove dev from structure tasdevice_hda, use dev in tasdevice_priv
- Remove 0 from { "tas2781-hda", 0}, & {"TXNW2781", 0},
- Add old hardware id "TIAS2781" for compatible with old production
- Add 2 devices in struct smi_node tas2781_hda, to compatible with 4 AMPs
v3:
- Move HID up to above /* Non-conforming _HID ... */ in scan.c, for avoid misunderstanding.
- Move HID up to above /* Non-conforming _HID ... */ in serial-multi-instantiate.c, for avoid misunderstanding.
- Change objs to y for snd-hda-scodec-tas2781-spi- in Makefile.
- Change format for some define in tas2781-spi.h.
- Add define for TASDEVICE_MAX_BOOK_NUM, TASDEVICE_MAX_PAGE.
- Move declare of "enum calib_data {" to header file from source file.
- Remove "enum device_catlog_id {" as only one platform was supported now.
- Remove "struct calidata", as we will save pure calibration data only.
- Remove "struct calidata", "enum device_catlog_id" in tasdevice_priv.
- Add calibration_data in tasdevice_priv to save pure calibration data.
- Remove declare of tasdevice_save_calibration() and tasdevice_apply_calibration(), as it will be used within same c file.
- Add below header files included in tas2781_hda_spi.c:
bits.h, mutex.h, property.h, time.h, types.h.
- Move two micro define to header file tas2781-spi.h.
- Change format of some micro define.
- Change format of some structure.
- Remove irq in tas2781_hda, as have it already in tasdevice_priv.
- Remove some local functions declare as not necessarily.
- Return error if regmap_write() failed.
- Change fixed value 2 to sizeof(data).
- Remove all of EXPORT_SYMBOL_GPL,
as all of function was called within same module.
- Remove empty line after last return in some functions.
- Remove some variable initialyzation.
- Remove variable sub, store acpi_subsystem_id directly.
- Remove wrong comments for device index, it's must, can't be NULL.
- Remove some local variables, use elements in structure directly.
- Append commas in last element of an array.
- Change calibration data process, didn't save all of calibration data in EFI, get in local, and save pure calibration data in tasdevice_priv.
- Call tasdevice_save_calibration() from function pointer in tasdevice_priv;
- Remove subid as one platform was supported only, needn't check.
- Add initialyzation for local variable.
- Move regmap initialyzation to before acpi read.
- Call tasdevice_apply_calibration() from function pointer in tasdevice_priv;
- Remove MODULE_IMPORT_NS(SND_SOC_TAS2781_FMWLIB), as all functions was performed within same module.
- Update format and variables declare order.
- Change format of multi conditions for if.
- Remove casting which is not needed.
- Change variables type to avoid casting.
- Remove Unneeded parentheses.
- Change if check to avoid goto.
- Add {} for keep same style.
- Remove some local variables, use elements in structure directly.
v2:
- Change depends on SPI to SPI_MASTER in sound/pci/hda/Kconfig
- Add select SND_HDA_SCODEC_COMPONENT in sound/pci/hda/Kconfig
- Change comp_generic_fixup() 5th parameter from "-%s:00" to "-%s:00-tas2781-hda.%d" in sound/pci/hda/patch_realtek.c
- Change chain_id from ALC285_FIXUP_THINKPAD_HEADSET_JACK to ALC285_FIXUP_HP_GPIO_LED in sound/pci/hda/patch_realtek.c
- Remove project name "Gemtree"
- Update information in file header of tas2781-spi.h.
- Remove useless micro define.
- Change TASDEVICE_I2CChecksum to TASDEVICE_Checksum
- Remove enum control_bus as current code support SPI only.
- Remove device define as current code support TAS2781 only.
- Remove spi_device **spi_devs in structure tasdevice_priv.
- Remove cal_binaryname in structure tasdevice_priv.
- Remove ndev in structure tasdevice_priv.
- Change isacpi and isspi, replace by control_bus(I2C or SPI).
- Remove void tasdevice_spi_dsp_remove(void *context).
- Add acpi_device and irq in structure tas2781_hda in tas2781_hda_spi.c.
- Remove parameter chn in all of registers access functions.
- Add tascodec_spi_init().
- Add chip select gpio set for SPI device.
- Change tasdevice_tuning_switch() to tasdevice_spi_tuning_switch().
- Change device offset from tas_priv->ndev to tas_priv->index.
- Change tasdevice_dsp_remove() to tasdevice_spi_dsp_remove().
- tasdevice_prmg_load() to tasdevice_spi_prmg_load().
- Change tasdevice_config_info_remove() to tasdevice_spi_config_info_remove().
- Add one dummy byte shift when read from page 2~127, or not book 0.
- Change tasdevice_spi_change_chn_book() to tasdevice_spi_switch_book()
- Perform put_device(physdev) before error return.
- Change calibration data id to 2781 from 2783 in EFI
- Change calibration data structure name in comments.
- Remove file name in tas2781_spi_fwlib.c.
- Remove #include <linux/i2c.h> as it not needed in SPI mode.
- Change TAB to speace in micro define in tas2781_spi_fwlib.c.
- Change to up-case for DSP.
- Change all of multi-line comments format, empty first line.
- Change all of sizeof(struct xx) to sizeof(*xx).
- Remove Explicit casting for variables compare to avoid possible fault.
- Return directly without goto.
- Change 1 << xx to BIT(xx).
- Remove deviceNumber[] as current SPI device will support one device only.
- Add memory free before return error.
- Change "buf[offset]; offset += 1" to buf[offset++].
- Remove some debug information print.
- Change firmware binary to single device mode.
- Change all bexx_to_cpup() to get_unaligned_bexx().
- Remove ndev process as current SPI device support single device only.
- Remove chn and chnend for single device support only.
- Change all of registers read/write function, remove parameter chn.
- Create new function for single write, burst write, delay, field write in tasdevice_process_block().

---
 drivers/acpi/scan.c                           |    1 +
 .../platform/x86/serial-multi-instantiate.c   |   12 +
 sound/pci/hda/Kconfig                         |   14 +
 sound/pci/hda/Makefile                        |    2 +
 sound/pci/hda/patch_realtek.c                 |   13 +
 sound/pci/hda/tas2781-spi.h                   |  148 ++
 sound/pci/hda/tas2781_hda_spi.c               | 1234 +++++++++
 sound/pci/hda/tas2781_spi_fwlib.c             | 2247 +++++++++++++++++
 8 files changed, 3671 insertions(+)
 create mode 100644 sound/pci/hda/tas2781-spi.h
 create mode 100644 sound/pci/hda/tas2781_hda_spi.c
 create mode 100644 sound/pci/hda/tas2781_spi_fwlib.c
drivers/acpi/scan.c +1 -0
index 503773707e01..9c08c5886370 100644
@@ -1760,6 +1760,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
 		{"CSC3557", },
 		{"INT33FE", },
 		{"INT3515", },
+		{"TXNW2781", },
 		/* Non-conforming _HID for Cirrus Logic already released */
 		{"CLSA0100", },
 		{"CLSA0101", },
drivers/platform/x86/serial-multi-instantiate.c +12 -0
index 97b9c6392230..23d46063423d 100644
@@ -368,6 +368,17 @@ static const struct smi_node cs35l57_hda = {
 	.bus_type = SMI_AUTO_DETECT,
 };
 
+static const struct smi_node tas2781_hda = {
+	.instances = {
+		{ "tas2781-hda", IRQ_RESOURCE_AUTO, 0 },
+		{ "tas2781-hda", IRQ_RESOURCE_AUTO, 0 },
+		{ "tas2781-hda", IRQ_RESOURCE_AUTO, 0 },
+		{ "tas2781-hda", IRQ_RESOURCE_AUTO, 0 },
+		{}
+	},
+	.bus_type = SMI_AUTO_DETECT,
+};
+
 /*
  * Note new device-ids must also be added to ignore_serial_bus_ids in
  * drivers/acpi/scan.c: acpi_device_enumeration_by_parent().
@@ -380,6 +391,7 @@ static const struct acpi_device_id smi_acpi_ids[] = {
 	{ "CSC3556", (unsigned long)&cs35l56_hda },
 	{ "CSC3557", (unsigned long)&cs35l57_hda },
 	{ "INT3515", (unsigned long)&int3515_data },
+	{ "TXNW2781", (unsigned long)&tas2781_hda },
 	/* Non-conforming _HID for Cirrus Logic already released */
 	{ "CLSA0100", (unsigned long)&cs35l41_hda },
 	{ "CLSA0101", (unsigned long)&cs35l41_hda },
sound/pci/hda/Kconfig +14 -0
index 0da625533afc..113161618788 100644
@@ -204,6 +204,20 @@ config SND_HDA_SCODEC_TAS2781_I2C
 comment "Set to Y if you want auto-loading the side codec driver"
 	depends on SND_HDA=y && SND_HDA_SCODEC_TAS2781_I2C=m
 
+config SND_HDA_SCODEC_TAS2781_SPI
+	tristate "Build TAS2781 HD-audio side codec support for SPI Bus"
+	depends on SPI_MASTER
+	depends on ACPI
+	depends on EFI
+	depends on SND_SOC
+	select CRC32_SARWATE
+	help
+	  Say Y or M here to include TAS2781 SPI HD-audio side codec support
+	  in snd-hda-intel driver, such as ALC287.
+
+comment "Set to Y if you want auto-loading the side codec driver"
+	depends on SND_HDA=y && SND_HDA_SCODEC_TAS2781_SPI=m
+
 config SND_HDA_CODEC_REALTEK
 	tristate "Build Realtek HD-audio codec support"
 	select SND_HDA_GENERIC
sound/pci/hda/Makefile +2 -0
index 058ca0a289e4..0bb5f0ce073f 100644
@@ -70,6 +70,8 @@ obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_SPI) += snd-hda-scodec-cs35l56-spi.o
 obj-$(CONFIG_SND_HDA_CS_DSP_CONTROLS) += snd-hda-cs-dsp-ctls.o
 obj-$(CONFIG_SND_HDA_SCODEC_COMPONENT) += snd-hda-scodec-component.o
 obj-$(CONFIG_SND_HDA_SCODEC_TAS2781_I2C) += snd-hda-scodec-tas2781-i2c.o
+obj-$(CONFIG_SND_HDA_SCODEC_TAS2781_SPI) += snd-hda-scodec-tas2781-spi.o
+snd-hda-scodec-tas2781-spi-y :=	tas2781_hda_spi.o tas2781_spi_fwlib.o
 
 # this must be the last entry after codec drivers;
 # otherwise the codec patches won't be hooked before the PCI probe
sound/pci/hda/patch_realtek.c +13 -0
index a696943aec0d..15832675bbd3 100644
@@ -6921,6 +6921,11 @@ static void tas2781_fixup_i2c(struct hda_codec *cdc,
 	comp_generic_fixup(cdc, action, "i2c", "TIAS2781", "-%s:00", 1);
 }
 
+static void tas2781_fixup_spi(struct hda_codec *cdc, const struct hda_fixup *fix, int action)
+{
+	comp_generic_fixup(cdc, action, "spi", "TXNW2781", "-%s:00-tas2781-hda.%d", 2);
+}
+
 static void yoga7_14arb7_fixup_i2c(struct hda_codec *cdc,
 	const struct hda_fixup *fix, int action)
 {
@@ -7498,6 +7503,7 @@ enum {
 	ALC236_FIXUP_DELL_DUAL_CODECS,
 	ALC287_FIXUP_CS35L41_I2C_2_THINKPAD_ACPI,
 	ALC287_FIXUP_TAS2781_I2C,
+	ALC245_FIXUP_TAS2781_SPI_2,
 	ALC287_FIXUP_YOGA7_14ARB7_I2C,
 	ALC245_FIXUP_HP_MUTE_LED_COEFBIT,
 	ALC245_FIXUP_HP_X360_MUTE_LEDS,
@@ -9688,6 +9694,12 @@ static const struct hda_fixup alc269_fixups[] = {
 		.chained = true,
 		.chain_id = ALC285_FIXUP_THINKPAD_HEADSET_JACK,
 	},
+	[ALC245_FIXUP_TAS2781_SPI_2] = {
+		.type = HDA_FIXUP_FUNC,
+		.v.func = tas2781_fixup_spi,
+		.chained = true,
+		.chain_id = ALC285_FIXUP_HP_GPIO_LED,
+	},
 	[ALC287_FIXUP_YOGA7_14ARB7_I2C] = {
 		.type = HDA_FIXUP_FUNC,
 		.v.func = yoga7_14arb7_fixup_i2c,
@@ -10156,6 +10168,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x103c, 0x8b8d, "HP", ALC236_FIXUP_HP_GPIO_LED),
 	SND_PCI_QUIRK(0x103c, 0x8b8f, "HP", ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED),
 	SND_PCI_QUIRK(0x103c, 0x8b92, "HP", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
+	SND_PCI_QUIRK(0x103c, 0x8b93, "HP Varcolac", ALC245_FIXUP_TAS2781_SPI_2),
 	SND_PCI_QUIRK(0x103c, 0x8b96, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
 	SND_PCI_QUIRK(0x103c, 0x8b97, "HP", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
 	SND_PCI_QUIRK(0x103c, 0x8bb3, "HP Slim OMEN", ALC287_FIXUP_CS35L41_I2C_2),
sound/pci/hda/tas2781-spi.h new file +148 -0

148 lines not on this page · raw message

sound/pci/hda/tas2781_hda_spi.c new file +1234 -0

1,234 lines not on this page · raw message

sound/pci/hda/tas2781_spi_fwlib.c new file +2247 -0

1,522 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.40.1

Part of the diff is not shown here. View the raw message.

#2 lore raw

Re: [PATCH v5 1/1] ALSA: hda/tas2781: Add tas2781 hda driver based on SPI

kernel test robot noticed the following build warnings:

Hi Baojun,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on tiwai-sound/for-linus rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v6.9 next-20240517] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Baojun-Xu/ALSA-hda-tas2781-Add-tas2781-hda-driver-based-on-SPI/20240519-230843
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link:    https://lore.kernel.org/r/20240519150433.760-2-baojun.xu%40ti.com
patch subject: [PATCH v5 1/1] ALSA: hda/tas2781: Add tas2781 hda driver based on SPI
config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20240520/[email protected]/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240520/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

sound/pci/hda/tas2781_hda_spi.c: In function 'tas2781_runtime_suspend':

>> sound/pci/hda/tas2781_hda_spi.c:1124:16: warning: unused variable 'ret' [-Wunused-variable]
    1124 |         int i, ret;
         |                ^~~
>> sound/pci/hda/tas2781_hda_spi.c:1124:13: warning: unused variable 'i' [-Wunused-variable]
    1124 |         int i, ret;
         |             ^
   sound/pci/hda/tas2781_hda_spi.c: In function 'tas2781_runtime_resume':
   sound/pci/hda/tas2781_hda_spi.c:1143:16: warning: unused variable 'ret' [-Wunused-variable]
    1143 |         int i, ret;
         |                ^~~
   sound/pci/hda/tas2781_hda_spi.c:1143:13: warning: unused variable 'i' [-Wunused-variable]
    1143 |         int i, ret;
         |             ^

vim +/ret +1124 sound/pci/hda/tas2781_hda_spi.c

1120
1121 static int tas2781_runtime_suspend(struct device *dev)
1122 {
1123 struct tas2781_hda *tas_hda = dev_get_drvdata(dev);

> 1124		int i, ret;

1125
1126 guard(mutex)(&tas_hda->priv->codec_lock);
1127
1128 if (tas_hda->priv->playback_started) {
1129 tasdevice_spi_tuning_switch(tas_hda->priv, 1);
1130 tas_hda->priv->playback_started = false;
1131 }
1132
1133 tas_hda->priv->cur_book = -1;
1134 tas_hda->priv->cur_prog = -1;
1135 tas_hda->priv->cur_conf = -1;
1136
1137 return 0;
1138 }
1139

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw

Re: [PATCH v5 1/1] ALSA: hda/tas2781: Add tas2781 hda driver based on SPI

In reply to Baojun Xu
kernel test robot noticed the following build warnings:

Hi Baojun,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on tiwai-sound/for-linus rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v6.9 next-20240517] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Baojun-Xu/ALSA-hda-tas2781-Add-tas2781-hda-driver-based-on-SPI/20240519-230843
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link:    https://lore.kernel.org/r/20240519150433.760-2-baojun.xu%40ti.com
patch subject: [PATCH v5 1/1] ALSA: hda/tas2781: Add tas2781 hda driver based on SPI
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20240520/[email protected]/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240520/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> sound/pci/hda/tas2781_spi_fwlib.c:1225:11: warning: result of comparison of constant 13656 with expression of type 'unsigned char' is always false [-Wtautological-constant-out-of-range-compare]
    1225 |             (reg == TASDEVICE_PAGE_REG(TAS2781_SA_COEFF_SWAP_REG)) &&
         |              ~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> sound/pci/hda/tas2781_spi_fwlib.c:1281:11: warning: result of comparison of constant 13660 with expression of type 'unsigned char' is always true [-Wtautological-constant-out-of-range-compare]
    1281 |             (reg <= (TASDEVICE_PAGE_REG(TAS2781_SA_COEFF_SWAP_REG) + 4)))
         |              ~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   sound/pci/hda/tas2781_spi_fwlib.c:1280:11: warning: result of comparison of constant 13656 with expression of type 'unsigned char' is always false [-Wtautological-constant-out-of-range-compare]
    1280 |             (reg >= TASDEVICE_PAGE_REG(TAS2781_SA_COEFF_SWAP_REG)) &&
         |              ~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   sound/pci/hda/tas2781_spi_fwlib.c:2112:3: warning: variable 'status' is uninitialized when used here [-Wuninitialized]
    2112 |                 status++;
         |                 ^~~~~~
   sound/pci/hda/tas2781_spi_fwlib.c:2050:12: note: initialize the variable 'status' to silence this warning
    2050 |         int status;
         |                   ^
         |                    = 0

4 warnings generated.

vim +1225 sound/pci/hda/tas2781_spi_fwlib.c

1206
1207 static int tasdev_multibytes_chksum(struct tasdevice_priv *tasdevice,
1208 unsigned char book, unsigned char page,
1209 unsigned char reg, unsigned int len)
1210 {
1211 struct tas_crc crc_data;
1212 unsigned char crc_chksum = 0;
1213 unsigned char nBuf1[128];
1214 int ret = 0, i;
1215 bool in;
1216
1217 if ((reg + len - 1) > 127) {
1218 ret = -EINVAL;
1219 dev_err(tasdevice->dev, "firmware error\n");
1220 goto end;
1221 }
1222
1223 if ((book == TASDEVICE_BOOK_ID(TAS2781_SA_COEFF_SWAP_REG)) &&

  1224		    (page == TASDEVICE_PAGE_ID(TAS2781_SA_COEFF_SWAP_REG)) &&
> 1225		    (reg == TASDEVICE_PAGE_REG(TAS2781_SA_COEFF_SWAP_REG)) &&
  1226		    (len == 4)) {
  1227			/* DSP swap command, pass */
  1228			ret = 0;
  1229			goto end;
  1230		}
  1231	
  1232		in = check_yram(&crc_data, book, page, reg, len);
  1233		if (!in)
  1234			goto end;
  1235	
  1236		if (len == 1) {
  1237			dev_err(tasdevice->dev, "firmware error\n");
  1238			ret = -EINVAL;
  1239			goto end;
  1240		}
  1241	
  1242		ret = tasdevice_spi_dev_bulk_read(tasdevice,
  1243			TASDEVICE_REG(book, page, crc_data.offset),
  1244			nBuf1, crc_data.len);
  1245		if (ret < 0)
  1246			goto end;
  1247	
  1248		for (i = 0; i < crc_data.len; i++) {
  1249			if ((book == TASDEVICE_BOOK_ID(TAS2781_SA_COEFF_SWAP_REG)) &&
  1250			    (page == TASDEVICE_PAGE_ID(TAS2781_SA_COEFF_SWAP_REG)) &&
  1251			    ((i + crc_data.offset) >=
  1252				TASDEVICE_PAGE_REG(TAS2781_SA_COEFF_SWAP_REG)) &&
  1253			    ((i + crc_data.offset) <=
  1254				(TASDEVICE_PAGE_REG(TAS2781_SA_COEFF_SWAP_REG) + 4)))
  1255				/* DSP swap command, bypass */
  1256				continue;
  1257			else
  1258				crc_chksum += crc8(tasdevice->crc8_lkp_tbl, &nBuf1[i],
  1259					1, 0);
  1260		}
  1261	
  1262		ret = crc_chksum;
  1263	
  1264	end:
  1265		return ret;
  1266	}
  1267	
  1268	static int do_singlereg_checksum(struct tasdevice_priv *tasdevice,
  1269		unsigned char book, unsigned char page,
  1270		unsigned char reg, unsigned char val)
  1271	{
  1272		struct tas_crc crc_data;
  1273		unsigned int nData1;
  1274		int ret = 0;
  1275		bool in;
  1276	
  1277		/* DSP swap command, pass */
  1278		if ((book == TASDEVICE_BOOK_ID(TAS2781_SA_COEFF_SWAP_REG)) &&
  1279		    (page == TASDEVICE_PAGE_ID(TAS2781_SA_COEFF_SWAP_REG)) &&
  1280		    (reg >= TASDEVICE_PAGE_REG(TAS2781_SA_COEFF_SWAP_REG)) &&
> 1281		    (reg <= (TASDEVICE_PAGE_REG(TAS2781_SA_COEFF_SWAP_REG) + 4)))

1282 return 0;
1283
1284 in = check_yram(&crc_data, book, page, reg, 1);
1285 if (!in)
1286 return 0;
1287 ret = tasdevice_spi_dev_read(tasdevice,
1288 TASDEVICE_REG(book, page, reg), &nData1);
1289 if (ret < 0)
1290 return ret;
1291
1292 if (nData1 != val) {
1293 dev_err(tasdevice->dev,
1294 "B[0x%x]P[0x%x]R[0x%x] W[0x%x], R[0x%x]\n",
1295 book, page, reg, val, nData1);
1296 tasdevice->err_code |= ERROR_YRAM_CRCCHK;
1297 return -EAGAIN;
1298 }
1299
1300 ret = crc8(tasdevice->crc8_lkp_tbl, &val, 1, 0);
1301
1302 return ret;
1303 }
1304

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki