From: Dan Carpenter <dan.carpenter@oracle.com>
To: FelixCuioc <FelixCui-oc@zhaoxin.com>
Cc: kbuild-all@lists.01.org, CobeChen-oc@zhaoxin.com,
kbuild@lists.01.org, linux-kernel@vger.kernel.org,
iommu@lists.linux-foundation.org, TonyWWang-oc@zhaoxin.com,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH 2/3] iommu/vt-d:Add support for probing ACPI device in RMRR
Date: Wed, 26 Aug 2020 13:58:47 +0300 [thread overview]
Message-ID: <20200826105847.GA5493@kadam> (raw)
In-Reply-To: <20200826102752.3776-3-FelixCui-oc@zhaoxin.com>
On Wed, Aug 26, 2020 at 06:27:51AM -0400, FelixCuioc wrote:
> After acpi device in RMRR is detected,it is necessary
> to establish a mapping for these devices.
> In acpi_device_create_direct_mappings(),create a mapping
> for the acpi device in RMRR.
> Add a helper to achieve the acpi namespace device can
> access the RMRR region.
>
> Signed-off-by: FelixCuioc <FelixCui-oc@zhaoxin.com>
> ---
> drivers/iommu/intel/iommu.c | 27 +++++++++++++++++++++++++++
> drivers/iommu/iommu.c | 6 ++++++
> include/linux/iommu.h | 3 +++
> 3 files changed, 36 insertions(+)
>
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index f774ef63d473..b31f02f41c96 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -4797,6 +4797,20 @@ static int __init platform_optin_force_iommu(void)
>
> return 1;
> }
> +static int acpi_device_create_direct_mappings(struct device *pn_dev, struct device *acpi_device)
Blank line.
> +{
> + struct iommu_group *group;
> +
> + acpi_device->bus->iommu_ops = &intel_iommu_ops;
> + group = iommu_group_get(pn_dev);
> + if (!group) {
> + pr_warn("ACPI name space devices create direct mappings wrong!\n");
> + return -1;
Use a proper error code. -ENOMEM? -EINVAL?
> + }
> + __acpi_device_create_direct_mappings(group, acpi_device);
> +
> + return 0;
> +}
>
> static int __init probe_acpi_namespace_devices(void)
> {
> @@ -4812,6 +4826,7 @@ static int __init probe_acpi_namespace_devices(void)
> struct acpi_device_physical_node *pn;
> struct iommu_group *group;
> struct acpi_device *adev;
> + struct device *pn_dev = NULL;
>
> if (dev->bus != &acpi_bus_type)
> continue;
> @@ -4822,6 +4837,7 @@ static int __init probe_acpi_namespace_devices(void)
> &adev->physical_node_list, node) {
> group = iommu_group_get(pn->dev);
> if (group) {
> + pn_dev = pn->dev;
> iommu_group_put(group);
> continue;
> }
> @@ -4830,7 +4846,18 @@ static int __init probe_acpi_namespace_devices(void)
> ret = iommu_probe_device(pn->dev);
> if (ret)
> break;
> + pn_dev = pn->dev;
> + }
> + if (pn_dev == NULL) {
Run checkpatch.pl --strict on this patch. Use "if (!pn_dev) {".
> + dev->bus->iommu_ops = &intel_iommu_ops;
> + ret = iommu_probe_device(dev);
> + if (ret) {
> + pr_err("acpi_device probe fail! ret:%d\n", ret);
> + return ret;
^^^^^^^^^^
This should be goto unlock;
> + }
> + return 0;
^^^^^^^^
> }
> + ret = acpi_device_create_direct_mappings(pn_dev, dev);
unlock:
> mutex_unlock(&adev->physical_node_lock);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
regards,
dan carpenter
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-08-26 11:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-26 10:27 [PATCH v2 0/3] Add support for ACPI device in RMRR to access reserved memory FelixCuioc
2020-08-26 10:27 ` [PATCH 1/3] iommu/vt-d:Add support for detecting ACPI device in RMRR FelixCuioc
2020-08-26 10:54 ` Dan Carpenter
2020-08-26 10:27 ` [PATCH 2/3] iommu/vt-d:Add support for probing " FelixCuioc
2020-08-26 10:58 ` Dan Carpenter [this message]
2020-08-26 10:27 ` [PATCH 3/3] iommu/vt-d:Add mutex_unlock() before returning FelixCuioc
2020-08-26 10:59 ` Dan Carpenter
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=20200826105847.GA5493@kadam \
--to=dan.carpenter@oracle.com \
--cc=CobeChen-oc@zhaoxin.com \
--cc=FelixCui-oc@zhaoxin.com \
--cc=TonyWWang-oc@zhaoxin.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=kbuild-all@lists.01.org \
--cc=kbuild@lists.01.org \
--cc=linux-kernel@vger.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).