lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6ca2134d-1b82-f8c3-3faa-b2a56f7ce36b@amd.com>
Date:   Tue, 16 Aug 2022 11:30:21 +0530
From:   Syed Saba Kareem <ssabakar@....com>
To:     Amadeusz Sławiński 
        <amadeuszx.slawinski@...ux.intel.com>,
        Syed Saba kareem <Syed.SabaKareem@....com>,
        broonie@...nel.org, alsa-devel@...a-project.org
Cc:     Sunil-kumar.Dommati@....com,
        open list <linux-kernel@...r.kernel.org>,
        Basavaraj.Hiregoudar@....com, Takashi Iwai <tiwai@...e.com>,
        Liam Girdwood <lgirdwood@...il.com>, mario.limonciello@....com,
        Vijendar.Mukunda@....com
Subject: Re: [PATCH 02/13] ASoC: amd: add Pink Sardine ACP PCI driver


On 8/12/22 19:49, Amadeusz Sławiński wrote:
> [CAUTION: External Email]
>
> On 8/12/2022 2:07 PM, Syed Saba kareem wrote:
>> ACP is a PCI audio device.
>> This patch adds PCI driver to bind to this device and get
>> PCI resources for Pink Sardine Platform.
>>
>> Signed-off-by: Syed Saba Kareem <Syed.SabaKareem@....com>
>> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@....com>
>> ---
>>   sound/soc/amd/ps/acp62.h  | 21 +++++++++
>>   sound/soc/amd/ps/pci-ps.c | 94 +++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 115 insertions(+)
>>   create mode 100644 sound/soc/amd/ps/acp62.h
>>   create mode 100644 sound/soc/amd/ps/pci-ps.c
>>
>> diff --git a/sound/soc/amd/ps/acp62.h b/sound/soc/amd/ps/acp62.h
>> new file mode 100644
>> index 000000000000..e91762240c93
>> --- /dev/null
>> +++ b/sound/soc/amd/ps/acp62.h
>> @@ -0,0 +1,21 @@
>> +/* SPDX-License-Identifier: GPL-2.0+ */
>> +/*
>> + * AMD ALSA SoC PDM Driver
>> + *
>> + * Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
>> + */
>> +
>> +#include <sound/acp62_chip_offset_byte.h>
>> +
>> +#define ACP_DEVICE_ID 0x15E2
>> +#define ACP62_PHY_BASE_ADDRESS 0x1240000
>> +
>> +static inline u32 acp62_readl(void __iomem *base_addr)
>> +{
>> +     return readl(base_addr - ACP62_PHY_BASE_ADDRESS);
>
> Can't you just define offsets in header, without ACP62_PHY_BASE_ADDRESS?
> Then you won't need to subtract the value here?
> I mean like:
> #define ACP_DMA_CNTL_0                                0x0000
> #define ACP_DMA_CNTL_1                                0x0004
> ...
> instead of
> #define ACP_DMA_CNTL_0                                0x1240000
> #define ACP_DMA_CNTL_1                                0x1240004
> ...
> Seems a bit weird to me, to just define values with offset if it is not
> needed...
>
Will fix it.

>> +}
>> +
>> +static inline void acp62_writel(u32 val, void __iomem *base_addr)
>> +{
>> +     writel(val, base_addr - ACP62_PHY_BASE_ADDRESS);
>> +}
>
> Same here
>
Will fix it.

>> diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c
>> new file mode 100644
>> index 000000000000..25169797275c
>> --- /dev/null
>> +++ b/sound/soc/amd/ps/pci-ps.c
>> @@ -0,0 +1,94 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * AMD Pink Sardine ACP PCI Driver
>> + *
>> + * Copyright 2022 Advanced Micro Devices, Inc.
>> + */
>> +
>> +#include <linux/pci.h>
>> +#include <linux/module.h>
>> +#include <linux/io.h>
>> +
>> +#include "acp62.h"
>> +
>> +struct acp62_dev_data {
>> +     void __iomem *acp62_base;
>> +};
>> +
>> +static int snd_acp62_probe(struct pci_dev *pci,
>> +                        const struct pci_device_id *pci_id)
>> +{
>> +     struct acp62_dev_data *adata;
>> +     u32 addr;
>> +     int ret;
>> +
>> +     /* Pink Sardine device check */
>> +     switch (pci->revision) {
>> +     case 0x63:
>> +             break;
>> +     default:
>> +             dev_dbg(&pci->dev, "acp62 pci device not found\n");
>> +             return -ENODEV;
>> +     }
>> +     if (pci_enable_device(pci)) {
>> +             dev_err(&pci->dev, "pci_enable_device failed\n");
>> +             return -ENODEV;
>> +     }
>> +
>> +     ret = pci_request_regions(pci, "AMD ACP6.2 audio");
>> +     if (ret < 0) {
>> +             dev_err(&pci->dev, "pci_request_regions failed\n");
>> +             goto disable_pci;
>> +     }
>> +             adata = devm_kzalloc(&pci->dev, sizeof(struct 
>> acp62_dev_data),
>> +                                  GFP_KERNEL);
>
> Wrong indentation in assignment above?
>
Will fix it.

>> +     if (!adata) {
>> +             ret = -ENOMEM;
>> +             goto release_regions;
>> +     }
>> +
>> +     addr = pci_resource_start(pci, 0);
>> +     adata->acp62_base = devm_ioremap(&pci->dev, addr,
>> +                                      pci_resource_len(pci, 0));
>> +     if (!adata->acp62_base) {
>> +             ret = -ENOMEM;
>> +             goto release_regions;
>> +     }
>> +     pci_set_master(pci);
>> +     pci_set_drvdata(pci, adata);
>> +     return 0;
>> +release_regions:
>> +     pci_release_regions(pci);
>> +disable_pci:
>> +     pci_disable_device(pci);
>> +
>> +     return ret;
>> +}
>> +
>> +static void snd_acp62_remove(struct pci_dev *pci)
>> +{
>> +     pci_release_regions(pci);
>> +     pci_disable_device(pci);
>> +}
>> +
>> +static const struct pci_device_id snd_acp62_ids[] = {
>> +     { PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_DEVICE_ID),
>
> This one is optional, but you could also use:
> PCI_VDEVICE(AMD, ACP_DEVICE_ID)
> which is bit shorter and at least to me seems a bit more readable.
Okay will use this.
>> +     .class = PCI_CLASS_MULTIMEDIA_OTHER << 8,
>> +     .class_mask = 0xffffff },
>> +     { 0, },
>> +};
>> +MODULE_DEVICE_TABLE(pci, snd_acp62_ids);
>> +
>> +static struct pci_driver ps_acp62_driver  = {
>> +     .name = KBUILD_MODNAME,
>> +     .id_table = snd_acp62_ids,
>> +     .probe = snd_acp62_probe,
>> +     .remove = snd_acp62_remove,
>> +};
>> +
>> +module_pci_driver(ps_acp62_driver);
>> +
>> +MODULE_AUTHOR("Vijendar.Mukunda@....com");
>> +MODULE_AUTHOR("Syed.SabaKareem@....com");
>> +MODULE_DESCRIPTION("AMD ACP Pink Sardine PCI driver");
>> +MODULE_LICENSE("GPL v2");
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ