[PATCH 33/50] wifi: ath12k: add mhi.c
Kalle Valo
kvalo at kernel.org
Tue Nov 8 06:00:49 PST 2022
Jeff Johnson <quic_jjohnson at quicinc.com> writes:
> On 8/12/2022 9:09 AM, Kalle Valo wrote:
>
>> From: Kalle Valo <quic_kvalo at quicinc.com>
>>
>> (Patches split into one patch per file for easier review, but the final
>> commit will be one big patch. See the cover letter for more info.)
>>
>> Signed-off-by: Kalle Valo <quic_kvalo at quicinc.com>
>> ---
>> drivers/net/wireless/ath/ath12k/mhi.c | 615 ++++++++++++++++++++++++++++++++++
>> 1 file changed, 615 insertions(+)
>>
>> diff --git a/drivers/net/wireless/ath/ath12k/mhi.c
>> b/drivers/net/wireless/ath/ath12k/mhi.c
>> new file mode 100644
>> index 000000000000..f77634994d97
>> --- /dev/null
>> +++ b/drivers/net/wireless/ath/ath12k/mhi.c
>> @@ -0,0 +1,615 @@
>> +// SPDX-License-Identifier: BSD-3-Clause-Clear
>> +/*
>> + * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
>> + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
>> + */
>> +
>> +#include <linux/msi.h>
>> +#include <linux/pci.h>
>> +
>> +#include "core.h"
>> +#include "debug.h"
>> +#include "mhi.h"
>> +#include "pci.h"
>> +
>> +#define MHI_TIMEOUT_DEFAULT_MS 90000
>> +
>> +static struct mhi_channel_config ath12k_mhi_channels_qcn9274[] = {
>
> should this be const?
> in struct mhi_controller_config:
> const struct mhi_channel_config *ch_cfg;
Fixed.
>> +static struct mhi_event_config ath12k_mhi_events_qcn9274[] = {
>
> seems this should be const
> but for some reason struct mhi_controller_config has:
> struct mhi_event_config *event_cfg;
>
> (not const) so this can't be const :(
>
> perhaps someone can propose a MHI interface change?
> especially since internally to MHI in parse_ev_cfg() we have:
> const struct mhi_event_config *event_cfg;
> [...]
> for (i = 0; i < num; i++) {
> event_cfg = &config->event_cfg[i];
>
> so it is treated as const
You submitted a patch for this, thanks for that:
https://lore.kernel.org/all/20220830171147.24338-1-quic_jjohnson@quicinc.com/
But oddly I cannot find anywhere in git, I sent a question about that to
the mhi list.
>> +static struct mhi_channel_config ath12k_mhi_channels_wcn7850[] = {
>
> const
Fixed.
>> +static struct mhi_event_config ath12k_mhi_events_wcn7850[] = {
>
> keep not const (for now) :(
Yup, hopefully we can fix this soon.
>> +struct mhi_controller_config ath12k_mhi_config_wcn7850 = {
>
> and this one should be const since it is registered via:
>
> int mhi_register_controller(struct mhi_controller *mhi_cntrl,
> const struct mhi_controller_config *config);
Fixed.
>> +static int ath12k_mhi_get_msi(struct ath12k_pci *ab_pci)
>> +{
>> + struct ath12k_base *ab = ab_pci->ab;
>> + u32 user_base_data, base_vector;
>> + int ret, num_vectors, i;
>> + int *irq;
>> +
>> + ret = ath12k_pci_get_user_msi_assignment(ab,
>> + "MHI", &num_vectors,
>> + &user_base_data, &base_vector);
>> + if (ret)
>> + return ret;
>> +
>> + ath12k_dbg(ab, ATH12K_DBG_PCI, "Number of assigned MSI for MHI is
>> %d, base vector is %d\n",
>> + num_vectors, base_vector);
>> +
>> + irq = kcalloc(num_vectors, sizeof(int), GFP_KERNEL);
>
> prefer sizeof(*irq)?
Fixed.
>> +void ath12k_mhi_unregister(struct ath12k_pci *ab_pci)
>> +{
>> + struct mhi_controller *mhi_ctrl = ab_pci->mhi_ctrl;
>> +
>> + mhi_unregister_controller(mhi_ctrl);
>> + kfree(mhi_ctrl->irq);
>> + mhi_free_controller(mhi_ctrl);
>
> consider setting ab_pci->mhi_ctrl = NULL to avoid dangling pointer?
Fixed.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
More information about the ath12k
mailing list