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: <CAHp75VcOVHspaUYTGHHx++1qsWZ0NL=7qhh3avd+cK2sqoj8Ew@mail.gmail.com>
Date:   Wed, 19 Aug 2020 13:40:27 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Sandeep Singh <Sandeep.Singh@....com>
Cc:     Jiri Kosina <jikos@...nel.org>,
        Benjamin Tissoires <benjamin.tissoires@...hat.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        linux-input <linux-input@...r.kernel.org>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        Jonathan Cameron <jic23@...nel.org>,
        linux-iio <linux-iio@...r.kernel.org>,
        Hans de Goede <hdegoede@...hat.com>,
        "Shah, Nehal-bakulchandra" <Nehal-bakulchandra.Shah@....com>,
        Richard Neumann <mail@...hard-neumann.de>,
        Marco Felsch <m.felsch@...gutronix.de>,
        Shyam-sundar.S-k@....com
Subject: Re: [PATCH v6 2/4] SFH: PCIe driver to add support of AMD sensor fusion

On Sun, Aug 9, 2020 at 1:25 PM Sandeep Singh <Sandeep.Singh@....com> wrote:

> AMD SFH uses HID over PCIe bus.SFH fw is part of MP2 processor
> (MP2 which is an ARMĀ® Cortex-M4 core based co-processor to x86) and
> it runs on MP2 where in driver resides on X86. This part of module

where the driver

> will communicate with MP2 FW and provide that data into DRAM

...

> +#
> +#

One is enough.

...

> +#define ACEL_EN                BIT(accel_idx)
> +#define GYRO_EN                BIT(gyro_idx)
> +#define MAGNO_EN       BIT(mag_idx)
> +#define ALS_EN         BIT(als_idx)

What is this?

...

> +int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
> +{
> +       int activestatus, num_of_sensors = 0;
> +

> +       if (!sensor_id)
> +               return -EINVAL;

Is it possible?

> +       privdata->activecontrolstatus = readl(privdata->mmio + AMD_P2C_MSG3);
> +       activestatus = privdata->activecontrolstatus >> 4;
> +       if (ACEL_EN  & activestatus)
> +               sensor_id[num_of_sensors++] = accel_idx;
> +
> +       if (GYRO_EN & activestatus)
> +               sensor_id[num_of_sensors++] = gyro_idx;
> +
> +       if (MAGNO_EN & activestatus)
> +               sensor_id[num_of_sensors++] = mag_idx;
> +
> +       if (ALS_EN & activestatus)
> +               sensor_id[num_of_sensors++] = als_idx;
> +
> +       return num_of_sensors;
> +}

...

> +static int amd_mp2_pci_init(struct amd_mp2_dev *privdata, struct pci_dev *pdev)
> +{
> +       int rc;
> +

> +       pci_set_drvdata(pdev, privdata);

This is better to have after initial resources were retrieved.

> +       pcim_enable_device(pdev);

> +       pcim_iomap_regions(pdev, BIT(2), DRIVER_NAME);

Where is the error check?

> +       privdata->mmio = pcim_iomap_table(pdev)[2];
> +       pci_set_master(pdev);
> +
> +       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
> +       if (rc)
> +               rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
> +       return rc;
> +}

What is the point to have this function separated from ->probe()?

...

> +       rc = amd_sfh_hid_client_init(privdata);
> +       if (rc)
> +               return rc;
> +       return 0;

return amd_...(...);

...

> +static const struct pci_device_id amd_mp2_pci_tbl[] = {
> +       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MP2) },

> +       {},

No comma.

> +};

...

> +#include <linux/pci.h>

I don't see any users of it in the file.
Use forward declaration instead.

> +#include <linux/types.h>

...

> +enum command_id {
> +       enable_sensor = 1,
> +       disable_sensor = 2,
> +       stop_all_sensors = 8,

> +       invalid_cmd = 0xf

GENMASK()?
(Will require bits.h)

> +};
> +
> +enum sensor_idx {
> +       accel_idx = 0,
> +       gyro_idx = 1,
> +       mag_idx = 2,
> +       als_idx = 19

+ comma.

> +};
> +
> +struct amd_mp2_dev {
> +       struct pci_dev *pdev;
> +       struct amdtp_cl_data *cl_data;

> +       void __iomem *mmio;

Is __iomem provided by linux/types.h? Otherwise include corresponding header.

> +       u32 activecontrolstatus;
> +};

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ