mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: "Winkler, Tomas" <tomas.winkler@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] mei: Migrate to pci_alloc_irq_vectors API
Date: Sun, 5 Aug 2018 13:18:55 +0200	[thread overview]
Message-ID: <d6a3e94c-2b05-f9d4-2522-37153e45c1d8@gmail.com> (raw)
In-Reply-To: <5B8DA87D05A7694D9FA63FD143655C1B9D97F6B4@hasmsx108.ger.corp.intel.com>

On 05.08.2018 13:02, Winkler, Tomas wrote:
>>
>> Update the driver to the pci_alloc_irq_vectors API, this allows to get rid of
>> legacy calls like pci_enable_msi(). Another benefit is that no driver change
>> would be needed in case the hardware starts supporting MSI-X.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> 
> Sorry, we are losing the ONE_SHOT flag here,  In spite that pci_enable_msi is marked as deprecated,  
ONE_SHOT flag isn't needed here. See commit f7368a550275 ("PCI: Use IRQF_ONESHOT if
pci_request_irq() called with no handler") and also following comment in __setup_irq():

* Drivers are often written to work w/o knowledge about the
* underlying irq chip implementation, so a request for a
* threaded irq without a primary hard irq context handler
* requires the ONESHOT flag to be set. Some irq chips like
* MSI based interrupts are per se one shot safe. Check the
* chip flags, so we can avoid the unmask dance at the end of
* the threaded handler for those.

> I don't see overall action on LKML to actually  deprecate it.
> For this change I would need to extensice testing on future and legacy devices, frankly  I prefer not to dig into it right now.

Sure, up to you.

> Thanks
> Tomas
> 
Rgds, Heiner

>> ---
>>  drivers/misc/mei/pci-me.c  | 25 +++++++++++--------------
>> drivers/misc/mei/pci-txe.c | 30 ++++++++++++++----------------
>>  2 files changed, 25 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index
>> 55ba1c41..a60376f0 100644
>> --- a/drivers/misc/mei/pci-me.c
>> +++ b/drivers/misc/mei/pci-me.c
>> @@ -149,7 +149,6 @@ static int mei_me_probe(struct pci_dev *pdev, const
>> struct pci_device_id *ent)
>>  	const struct mei_cfg *cfg;
>>  	struct mei_device *dev;
>>  	struct mei_me_hw *hw;
>> -	unsigned int irqflags;
>>  	int err;
>>
>>  	cfg = mei_me_get_cfg(ent->driver_data); @@ -196,18 +195,16 @@
>> static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id
>> *ent)
>>  	hw = to_me_hw(dev);
>>  	hw->mem_addr = pcim_iomap_table(pdev)[0];
>>
>> -	pci_enable_msi(pdev);
>> -
>> -	 /* request and enable interrupt */
>> -	irqflags = pci_dev_msi_enabled(pdev) ? IRQF_ONESHOT :
>> IRQF_SHARED;
>> +	err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
>> +	if (err < 0)
>> +		goto end;
>>
>> -	err = request_threaded_irq(pdev->irq,
>> -			mei_me_irq_quick_handler,
>> -			mei_me_irq_thread_handler,
>> -			irqflags, KBUILD_MODNAME, dev);
>> +	/* request and enable interrupt */
>> +	err = pci_request_irq(pdev, 0, mei_me_irq_quick_handler,
>> +			      mei_me_irq_thread_handler, dev,
>> KBUILD_MODNAME);
>>  	if (err) {
>> -		dev_err(&pdev->dev, "request_threaded_irq failure. irq =
>> %d\n",
>> -		       pdev->irq);
>> +		pci_err(pdev, "pci_request_irq failure. irq = %d\n",
>> +			pci_irq_vector(pdev, 0));
>>  		goto end;
>>  	}
>>
>> @@ -258,7 +255,7 @@ static int mei_me_probe(struct pci_dev *pdev, const
>> struct pci_device_id *ent)
>>  release_irq:
>>  	mei_cancel_work(dev);
>>  	mei_disable_interrupts(dev);
>> -	free_irq(pdev->irq, dev);
>> +	pci_free_irq(pdev, 0, dev);
>>  end:
>>  	dev_err(&pdev->dev, "initialization failed.\n");
>>  	return err;
>> @@ -287,7 +284,7 @@ static void mei_me_shutdown(struct pci_dev *pdev)
>>  	mei_me_unset_pm_domain(dev);
>>
>>  	mei_disable_interrupts(dev);
>> -	free_irq(pdev->irq, dev);
>> +	pci_free_irq(pdev, 0, dev);
>>  }
>>
>>  /**
>> @@ -316,7 +313,7 @@ static void mei_me_remove(struct pci_dev *pdev)
>>
>>  	mei_disable_interrupts(dev);
>>
>> -	free_irq(pdev->irq, dev);
>> +	pci_free_irq(pdev, 0, dev);
>>
>>  	mei_deregister(dev);
>>  }
>> diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c index
>> b8a49581..3ea2b8f6 100644
>> --- a/drivers/misc/mei/pci-txe.c
>> +++ b/drivers/misc/mei/pci-txe.c
>> @@ -64,6 +64,7 @@ static int mei_txe_probe(struct pci_dev *pdev, const
>> struct pci_device_id *ent)  {
>>  	struct mei_device *dev;
>>  	struct mei_txe_hw *hw;
>> +	irq_handler_t qh = NULL;
>>  	const int mask = BIT(SEC_BAR) | BIT(BRIDGE_BAR);
>>  	int err;
>>
>> @@ -100,25 +101,22 @@ static int mei_txe_probe(struct pci_dev *pdev,
>> const struct pci_device_id *ent)
>>  	hw = to_txe_hw(dev);
>>  	hw->mem_addr = pcim_iomap_table(pdev);
>>
>> -	pci_enable_msi(pdev);
>> +	err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
>> +	if (err < 0)
>> +		goto end;
>>
>>  	/* clear spurious interrupts */
>>  	mei_clear_interrupts(dev);
>>
>> +	if (!pci_dev_msi_enabled(pdev))
>> +		qh = mei_txe_irq_quick_handler;
>> +
>>  	/* request and enable interrupt  */
>> -	if (pci_dev_msi_enabled(pdev))
>> -		err = request_threaded_irq(pdev->irq,
>> -			NULL,
>> -			mei_txe_irq_thread_handler,
>> -			IRQF_ONESHOT, KBUILD_MODNAME, dev);
>> -	else
>> -		err = request_threaded_irq(pdev->irq,
>> -			mei_txe_irq_quick_handler,
>> -			mei_txe_irq_thread_handler,
>> -			IRQF_SHARED, KBUILD_MODNAME, dev);
>> +	err = pci_request_irq(pdev, 0, qh, mei_txe_irq_thread_handler,
>> +			      dev, KBUILD_MODNAME);
>>  	if (err) {
>> -		dev_err(&pdev->dev, "mei: request_threaded_irq failure. irq
>> = %d\n",
>> -			pdev->irq);
>> +		pci_err(pdev, "mei: pci_request_irq failure. irq = %d\n",
>> +			pci_irq_vector(pdev, 0));
>>  		goto end;
>>  	}
>>
>> @@ -162,7 +160,7 @@ static int mei_txe_probe(struct pci_dev *pdev, const
>> struct pci_device_id *ent)
>>  release_irq:
>>  	mei_cancel_work(dev);
>>  	mei_disable_interrupts(dev);
>> -	free_irq(pdev->irq, dev);
>> +	pci_free_irq(pdev, 0, dev);
>>  end:
>>  	dev_err(&pdev->dev, "initialization failed.\n");
>>  	return err;
>> @@ -191,7 +189,7 @@ static void mei_txe_shutdown(struct pci_dev *pdev)
>>  	mei_txe_unset_pm_domain(dev);
>>
>>  	mei_disable_interrupts(dev);
>> -	free_irq(pdev->irq, dev);
>> +	pci_free_irq(pdev, 0, dev);
>>  }
>>
>>  /**
>> @@ -219,7 +217,7 @@ static void mei_txe_remove(struct pci_dev *pdev)
>>  	mei_txe_unset_pm_domain(dev);
>>
>>  	mei_disable_interrupts(dev);
>> -	free_irq(pdev->irq, dev);
>> +	pci_free_irq(pdev, 0, dev);
>>
>>  	mei_deregister(dev);
>>  }
>> --
>> 2.18.0
>>
> 


  reply	other threads:[~2018-08-05 11:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03 21:37 [PATCH 0/3] mei: migrate to pci_alloc_irq_vectors and smaller improvements Heiner Kallweit
2018-08-03 21:39 ` [PATCH 1/3] mei: Don't free irq when suspending Heiner Kallweit
2018-08-03 21:40 ` [PATCH 2/3] mei: Migrate to pci_alloc_irq_vectors API Heiner Kallweit
2018-08-05 11:02   ` Winkler, Tomas
2018-08-05 11:18     ` Heiner Kallweit [this message]
2018-08-03 21:42 ` [PATCH 3/3] mei: Improve usage of mei_start Heiner Kallweit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d6a3e94c-2b05-f9d4-2522-37153e45c1d8@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tomas.winkler@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®