2022-09-07 14:32:47

by kernel test robot

[permalink] [raw]
Subject: [mani-mhi:mhi-next 2/3] drivers/bus/mhi/host/pci_generic.c:734:60: error: assignment of member 'irq' in read-only object

tree: https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git mhi-next
head: 0a3b31f6259f4849e4e93731d4c8d7910be072a7
commit: 4a98958ca237a4b7974ea1ec2092b3666bdd26ab [2/3] bus: mhi: host: make mhi_controller_config::event_cfg const
config: i386-randconfig-a001 (https://download.01.org/0day-ci/archive/20220907/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git/commit/?id=4a98958ca237a4b7974ea1ec2092b3666bdd26ab
git remote add mani-mhi https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git
git fetch --no-tags mani-mhi mhi-next
git checkout 4a98958ca237a4b7974ea1ec2092b3666bdd26ab
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

drivers/bus/mhi/host/pci_generic.c: In function 'mhi_pci_get_irqs':
>> drivers/bus/mhi/host/pci_generic.c:734:60: error: assignment of member 'irq' in read-only object
734 | mhi_cntrl_config->event_cfg[i].irq = 0;
| ^


vim +/irq +734 drivers/bus/mhi/host/pci_generic.c

855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 708
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 709 static int mhi_pci_get_irqs(struct mhi_controller *mhi_cntrl,
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 710 const struct mhi_controller_config *mhi_cntrl_config)
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 711 {
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 712 struct pci_dev *pdev = to_pci_dev(mhi_cntrl->cntrl_dev);
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 713 int nr_vectors, i;
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 714 int *irq;
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 715
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 716 /*
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 717 * Alloc one MSI vector for BHI + one vector per event ring, ideally...
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 718 * No explicit pci_free_irq_vectors required, done by pcim_release.
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 719 */
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 720 mhi_cntrl->nr_irqs = 1 + mhi_cntrl_config->num_events;
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 721
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 722 nr_vectors = pci_alloc_irq_vectors(pdev, 1, mhi_cntrl->nr_irqs, PCI_IRQ_MSI);
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 723 if (nr_vectors < 0) {
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 724 dev_err(&pdev->dev, "Error allocating MSI vectors %d\n",
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 725 nr_vectors);
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 726 return nr_vectors;
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 727 }
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 728
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 729 if (nr_vectors < mhi_cntrl->nr_irqs) {
b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 730 dev_warn(&pdev->dev, "using shared MSI\n");
b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 731
b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 732 /* Patch msi vectors, use only one (shared) */
b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 733 for (i = 0; i < mhi_cntrl_config->num_events; i++)
b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 @734 mhi_cntrl_config->event_cfg[i].irq = 0;
b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 735 mhi_cntrl->nr_irqs = 1;
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 736 }
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 737
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 738 irq = devm_kcalloc(&pdev->dev, mhi_cntrl->nr_irqs, sizeof(int), GFP_KERNEL);
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 739 if (!irq)
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 740 return -ENOMEM;
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 741
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 742 for (i = 0; i < mhi_cntrl->nr_irqs; i++) {
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 743 int vector = i >= nr_vectors ? (nr_vectors - 1) : i;
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 744
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 745 irq[i] = pci_irq_vector(pdev, vector);
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 746 }
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 747
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 748 mhi_cntrl->irq = irq;
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 749
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 750 return 0;
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 751 }
855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 752

:::::: The code at line 734 was first introduced by commit
:::::: b91c3b30e2267265cd7e67cb3d0c99c48c02b001 mhi: pci_generic: Fix shared MSI vector support

:::::: TO: Loic Poulain <[email protected]>
:::::: CC: Manivannan Sadhasivam <[email protected]>

--
0-DAY CI Kernel Test Service
https://01.org/lkp


2022-09-07 16:59:25

by Manivannan Sadhasivam

[permalink] [raw]
Subject: Re: [mani-mhi:mhi-next 2/3] drivers/bus/mhi/host/pci_generic.c:734:60: error: assignment of member 'irq' in read-only object

On Wed, Sep 07, 2022 at 09:47:42PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git mhi-next
> head: 0a3b31f6259f4849e4e93731d4c8d7910be072a7
> commit: 4a98958ca237a4b7974ea1ec2092b3666bdd26ab [2/3] bus: mhi: host: make mhi_controller_config::event_cfg const
> config: i386-randconfig-a001 (https://download.01.org/0day-ci/archive/20220907/[email protected]/config)
> compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
> reproduce (this is a W=1 build):
> # https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git/commit/?id=4a98958ca237a4b7974ea1ec2092b3666bdd26ab
> git remote add mani-mhi https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git
> git fetch --no-tags mani-mhi mhi-next
> git checkout 4a98958ca237a4b7974ea1ec2092b3666bdd26ab
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <[email protected]>
>
> All errors (new ones prefixed by >>):
>
> drivers/bus/mhi/host/pci_generic.c: In function 'mhi_pci_get_irqs':
> >> drivers/bus/mhi/host/pci_generic.c:734:60: error: assignment of member 'irq' in read-only object
> 734 | mhi_cntrl_config->event_cfg[i].irq = 0;

Ah, so this is why I didn't make it constant in the first place...
Dropped the patch now.

Thanks,
Mani

> | ^
>
>
> vim +/irq +734 drivers/bus/mhi/host/pci_generic.c
>
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 708
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 709 static int mhi_pci_get_irqs(struct mhi_controller *mhi_cntrl,
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 710 const struct mhi_controller_config *mhi_cntrl_config)
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 711 {
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 712 struct pci_dev *pdev = to_pci_dev(mhi_cntrl->cntrl_dev);
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 713 int nr_vectors, i;
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 714 int *irq;
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 715
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 716 /*
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 717 * Alloc one MSI vector for BHI + one vector per event ring, ideally...
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 718 * No explicit pci_free_irq_vectors required, done by pcim_release.
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 719 */
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 720 mhi_cntrl->nr_irqs = 1 + mhi_cntrl_config->num_events;
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 721
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 722 nr_vectors = pci_alloc_irq_vectors(pdev, 1, mhi_cntrl->nr_irqs, PCI_IRQ_MSI);
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 723 if (nr_vectors < 0) {
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 724 dev_err(&pdev->dev, "Error allocating MSI vectors %d\n",
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 725 nr_vectors);
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 726 return nr_vectors;
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 727 }
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 728
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 729 if (nr_vectors < mhi_cntrl->nr_irqs) {
> b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 730 dev_warn(&pdev->dev, "using shared MSI\n");
> b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 731
> b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 732 /* Patch msi vectors, use only one (shared) */
> b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 733 for (i = 0; i < mhi_cntrl_config->num_events; i++)
> b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 @734 mhi_cntrl_config->event_cfg[i].irq = 0;
> b91c3b30e226726 drivers/bus/mhi/pci_generic.c Loic Poulain 2021-01-05 735 mhi_cntrl->nr_irqs = 1;
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 736 }
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 737
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 738 irq = devm_kcalloc(&pdev->dev, mhi_cntrl->nr_irqs, sizeof(int), GFP_KERNEL);
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 739 if (!irq)
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 740 return -ENOMEM;
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 741
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 742 for (i = 0; i < mhi_cntrl->nr_irqs; i++) {
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 743 int vector = i >= nr_vectors ? (nr_vectors - 1) : i;
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 744
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 745 irq[i] = pci_irq_vector(pdev, vector);
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 746 }
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 747
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 748 mhi_cntrl->irq = irq;
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 749
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 750 return 0;
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 751 }
> 855a70c12021bdc drivers/bus/mhi/pci_generic.c Loic Poulain 2020-10-21 752
>
> :::::: The code at line 734 was first introduced by commit
> :::::: b91c3b30e2267265cd7e67cb3d0c99c48c02b001 mhi: pci_generic: Fix shared MSI vector support
>
> :::::: TO: Loic Poulain <[email protected]>
> :::::: CC: Manivannan Sadhasivam <[email protected]>
>
> --
> 0-DAY CI Kernel Test Service
> https://01.org/lkp

--
மணிவண்ணன் சதாசிவம்

2022-09-07 17:12:52

by Jeff Johnson

[permalink] [raw]
Subject: Re: [mani-mhi:mhi-next 2/3] drivers/bus/mhi/host/pci_generic.c:734:60: error: assignment of member 'irq' in read-only object

On 9/7/2022 9:45 AM, Manivannan Sadhasivam wrote:
> On Wed, Sep 07, 2022 at 09:47:42PM +0800, kernel test robot wrote:
>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git mhi-next
>> head: 0a3b31f6259f4849e4e93731d4c8d7910be072a7
>> commit: 4a98958ca237a4b7974ea1ec2092b3666bdd26ab [2/3] bus: mhi: host: make mhi_controller_config::event_cfg const
>> config: i386-randconfig-a001 (https://download.01.org/0day-ci/archive/20220907/[email protected]/config)
>> compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
>> reproduce (this is a W=1 build):
>> # https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git/commit/?id=4a98958ca237a4b7974ea1ec2092b3666bdd26ab
>> git remote add mani-mhi https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git
>> git fetch --no-tags mani-mhi mhi-next
>> git checkout 4a98958ca237a4b7974ea1ec2092b3666bdd26ab
>> # save the config file
>> mkdir build_dir && cp config build_dir/.config
>> make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
>>
>> If you fix the issue, kindly add following tag where applicable
>> Reported-by: kernel test robot <[email protected]>
>>
>> All errors (new ones prefixed by >>):
>>
>> drivers/bus/mhi/host/pci_generic.c: In function 'mhi_pci_get_irqs':
>>>> drivers/bus/mhi/host/pci_generic.c:734:60: error: assignment of member 'irq' in read-only object
>> 734 | mhi_cntrl_config->event_cfg[i].irq = 0;
>
> Ah, so this is why I didn't make it constant in the first place...
> Dropped the patch now.
>
> Thanks,
> Mani

I believe it should be const in the MHI config, but in this case the
declaration in drivers/bus/mhi/host/pci_generic.c can't be const.

Let me respin the patch with this in mind.

2022-09-07 17:27:49

by Jeff Johnson

[permalink] [raw]
Subject: Re: [mani-mhi:mhi-next 2/3] drivers/bus/mhi/host/pci_generic.c:734:60: error: assignment of member 'irq' in read-only object

On 9/7/2022 9:56 AM, Jeff Johnson wrote:
> On 9/7/2022 9:45 AM, Manivannan Sadhasivam wrote:
>> On Wed, Sep 07, 2022 at 09:47:42PM +0800, kernel test robot wrote:
>>> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git
>>> mhi-next
>>> head:   0a3b31f6259f4849e4e93731d4c8d7910be072a7
>>> commit: 4a98958ca237a4b7974ea1ec2092b3666bdd26ab [2/3] bus: mhi:
>>> host: make mhi_controller_config::event_cfg const
>>> config: i386-randconfig-a001
>>> (https://download.01.org/0day-ci/archive/20220907/[email protected]/config)
>>> compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
>>> reproduce (this is a W=1 build):
>>>          #
>>> https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git/commit/?id=4a98958ca237a4b7974ea1ec2092b3666bdd26ab
>>>          git remote add mani-mhi
>>> https://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git
>>>          git fetch --no-tags mani-mhi mhi-next
>>>          git checkout 4a98958ca237a4b7974ea1ec2092b3666bdd26ab
>>>          # save the config file
>>>          mkdir build_dir && cp config build_dir/.config
>>>          make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
>>>
>>> If you fix the issue, kindly add following tag where applicable
>>> Reported-by: kernel test robot <[email protected]>
>>>
>>> All errors (new ones prefixed by >>):
>>>
>>>     drivers/bus/mhi/host/pci_generic.c: In function 'mhi_pci_get_irqs':
>>>>> drivers/bus/mhi/host/pci_generic.c:734:60: error: assignment of
>>>>> member 'irq' in read-only object
>>>       734 |
>>> mhi_cntrl_config->event_cfg[i].irq = 0;
>>
>> Ah, so this is why I didn't make it constant in the first place...
>> Dropped the patch now.
>>
>> Thanks,
>> Mani
>
> I believe it should be const in the MHI config, but in this case the
> declaration in drivers/bus/mhi/host/pci_generic.c can't be const.
>
> Let me respin the patch with this in mind.
>

NM, just drop it. Too much pain for the little gain I was hoping for in
the ath drivers :)