linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chen Baozi <chenbaozi@phytium.com.cn>
To: Marc Zyngier <maz@kernel.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org, Guohanjun <guohanjun@huawei.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC PATCH V2] acpi/irq: Add stacked IRQ domain support to PCI interrupt link
Date: Wed, 18 Nov 2020 21:36:11 +0800	[thread overview]
Message-ID: <9FC46D81-B76F-46EC-B022-396F59806803@phytium.com.cn> (raw)
In-Reply-To: <c4bc3817074c0793615440c6220f3813@kernel.org>

Hi Marc,

> On Nov 18, 2020, at 5:27 PM, Marc Zyngier <maz@kernel.org> wrote:
> 
> Hi Chen,
> 
> On top of Bjorn's comments:
> 
> On 2020-11-17 13:42, Chen Baozi wrote:
>> 
>> ---
>> drivers/acpi/irq.c          | 22 +++++++++++++++++++++-
>> drivers/acpi/pci_irq.c      |  6 ++++--
>> drivers/acpi/pci_link.c     | 17 +++++++++++++++--
>> include/acpi/acpi_drivers.h |  2 +-
>> include/linux/acpi.h        |  4 ++++
>> 5 files changed, 45 insertions(+), 6 deletions(-)
>> diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c
>> index e209081d644b..e78a44815c44 100644
>> --- a/drivers/acpi/irq.c
>> +++ b/drivers/acpi/irq.c
>> @@ -81,6 +81,25 @@ void acpi_unregister_gsi(u32 gsi)
>> }
>> EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
>> +int acpi_register_irq(struct device *dev, u32 irq, int trigger,
>> +		      int polarity, struct fwnode_handle *domain_id)
>> +{
>> +	struct irq_fwspec fwspec;
>> +
>> +	if (WARN_ON(!domain_id)) {
>> +		pr_warn("GSI: No registered irqchip, giving up\n");
> 
> A fwnode_handle is not an irqchip. It's just an opaque identifier
> for a HW block. Furthermore, there is no need to have both a WARN_ON()
> and a pr_warn(). Please pick one.
> 
> I'd also suggest you rename domain_id to fwnode, which is the commonly
> used idiom (yes, I know about the unfortunate precedent in acpi_register_gsi()).
> 
>> +		return -EINVAL;
>> +	}
>> +
>> +	fwspec.fwnode = domain_id;
>> +	fwspec.param[0] = irq;
>> +	fwspec.param[1] = acpi_dev_get_irq_type(trigger, polarity);
>> +	fwspec.param_count = 2;
>> +
>> +	return irq_create_fwspec_mapping(&fwspec);
>> +}
>> +EXPORT_SYMBOL_GPL(acpi_register_irq);
> 
> By the way, this is almost an exact duplicate of acpi_register_gsi().
> You definitely want to make this code common.
> 
>> @@ -115,6 +134,7 @@ acpi_get_irq_source_fwhandle(const struct
>> acpi_resource_source *source)
>> 	acpi_bus_put_acpi_device(device);
>> 	return result;
>> }
>> +EXPORT_SYMBOL_GPL(acpi_get_irq_source_fwhandle);
>> /*
>>  * Context for the resource walk used to lookup IRQ resources.
>> diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
>> index 14ee631cb7cf..19296d70c95c 100644
>> --- a/drivers/acpi/pci_irq.c
>> +++ b/drivers/acpi/pci_irq.c
>> @@ -410,6 +410,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
>> 	char *link = NULL;
>> 	char link_desc[16];
>> 	int rc;
>> +	struct fwnode_handle *irq_domain;
> 
> fwnode_handle is most definitely not an IRQ domain.
> 
>> @@ -140,6 +143,12 @@ static acpi_status
>> acpi_pci_link_check_possible(struct acpi_resource *resource,
>> 			link->irq.triggering = p->triggering;
>> 			link->irq.polarity = p->polarity;
>> 			link->irq.resource_type = ACPI_RESOURCE_TYPE_EXTENDED_IRQ;
>> +			if (p->resource_source.string_length) {
>> +				rs->index = p->resource_source.index;
>> +				rs->string_length = p->resource_source.string_length;
>> +				rs->string_ptr = kmalloc(rs->string_length, GFP_KERNEL);
>> +				strcpy(rs->string_ptr, p->resource_source.string_ptr);
> 
> We have kstrdup() for this kind of things, as using rs->string_length to allocate
> the buffer and strcpy() to copy it feels... dangerous.
> 
>> +			}
>> 			break;
>> 		}
>> 	default:
>> @@ -612,7 +622,7 @@ static int acpi_pci_link_allocate(struct
>> acpi_pci_link *link)
>>  * failure: return -1
>>  */
>> int acpi_pci_link_allocate_irq(acpi_handle handle, int index, int *triggering,
>> -			       int *polarity, char **name)
>> +			       int *polarity, char **name, struct fwnode_handle **irq_domain)
> 
> Same remark about the naming.

Thanks. It is very helpful. I’ll fix it in next version.

Baozi.


  reply	other threads:[~2020-11-18 13:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17 13:42 [RFC PATCH V2] acpi/irq: Add stacked IRQ domain support to PCI interrupt link Chen Baozi
2020-11-17 18:57 ` Bjorn Helgaas
2020-11-18 10:37   ` Chen Baozi
2020-11-18 13:45   ` Ard Biesheuvel
2020-11-18 13:50     ` Rafael J. Wysocki
2020-11-18  9:27 ` Marc Zyngier
2020-11-18 13:36   ` Chen Baozi [this message]
2020-11-18  9:51 ` Lorenzo Pieralisi
2020-11-18 14:05   ` Chen Baozi
2020-11-19 10:37     ` Lorenzo Pieralisi

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=9FC46D81-B76F-46EC-B022-396F59806803@phytium.com.cn \
    --to=chenbaozi@phytium.com.cn \
    --cc=ardb@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=guohanjun@huawei.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=maz@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).