xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: elena.ufimtseva@oracle.com
Cc: kevin.tian@intel.com, tim@xen.org, xen-devel@lists.xen.org,
	jbeulich@suse.com, yang.z.zhang@intel.com,
	boris.ostrovsky@oracle.com
Subject: Re: [PATCH v8 2/4] iommu VT-d: separate rmrr addition function
Date: Wed, 8 Jul 2015 13:30:22 -0400	[thread overview]
Message-ID: <20150708173022.GB17261@l.oracle.com> (raw)
In-Reply-To: <1435707242-24937-3-git-send-email-elena.ufimtseva@oracle.com>

On Tue, Jun 30, 2015 at 07:34:00PM -0400, elena.ufimtseva@oracle.com wrote:
> From: Elena Ufimtseva <elena.ufimtseva@oracle.com>
> 
> In preparation for auxiliary RMRR data provided on Xen
> command line, make RMRR adding a separate function.
> Also free memery for rmrr device scope in error path.
> I will also post additional patch with cleanups to address                      
> other non-functional changes as per Jan's review of v7 of this patch.

Those two linesL "I will also .." should be below the --- as there
is no need for that in the final git tree.

Otherwise looks OK.
> 
> Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
> ---
> Changes since v7:
>  - removed bogus debug introduced in previous version;
> 
>  xen/drivers/passthrough/vtd/dmar.c | 126 +++++++++++++++++++------------------
>  1 file changed, 65 insertions(+), 61 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/vtd/dmar.c b/xen/drivers/passthrough/vtd/dmar.c
> index 77ef708..a8e1e5d 100644
> --- a/xen/drivers/passthrough/vtd/dmar.c
> +++ b/xen/drivers/passthrough/vtd/dmar.c
> @@ -585,6 +585,68 @@ out:
>      return ret;
>  }
>  
> +static int register_one_rmrr(struct acpi_rmrr_unit *rmrru)
> +{
> +    bool_t ignore = 0;
> +    unsigned int i = 0;
> +    int ret = 0;
> +
> +    /* Skip checking if segment is not accessible yet. */
> +    if ( !pci_known_segment(rmrru->segment) )
> +        i = UINT_MAX;
> +
> +    for ( ; i < rmrru->scope.devices_cnt; i++ )
> +    {
> +        u8 b = PCI_BUS(rmrru->scope.devices[i]);
> +        u8 d = PCI_SLOT(rmrru->scope.devices[i]);
> +        u8 f = PCI_FUNC(rmrru->scope.devices[i]);
> +
> +        if ( pci_device_detect(rmrru->segment, b, d, f) == 0 )
> +        {
> +            dprintk(XENLOG_WARNING VTDPREFIX,
> +                    " Non-existent device (%04x:%02x:%02x.%u) is reported"
> +                    " in RMRR (%"PRIx64", %"PRIx64")'s scope!\n",
> +                    rmrru->segment, b, d, f,
> +                    rmrru->base_address, rmrru->end_address);
> +            ignore = 1;
> +        }
> +        else
> +        {
> +            ignore = 0;
> +            break;
> +        }
> +    }
> +
> +    if ( ignore )
> +    {
> +        dprintk(XENLOG_WARNING VTDPREFIX,
> +                "  Ignore the RMRR (%"PRIx64", %"PRIx64") due to "
> +                "devices under its scope are not PCI discoverable!\n",
> +            rmrru->base_address, rmrru->end_address);
> +        scope_devices_free(&rmrru->scope);
> +        xfree(rmrru);
> +    }
> +    else if ( rmrru->base_address > rmrru->end_address )
> +    {
> +        dprintk(XENLOG_WARNING VTDPREFIX,
> +                "  The RMRR (%"PRIx64", %"PRIx64") is incorrect!\n",
> +                rmrru->base_address, rmrru->end_address);
> +        scope_devices_free(&rmrru->scope);
> +        xfree(rmrru);
> +        ret = -EFAULT;
> +    }
> +    else
> +    {
> +        if ( iommu_verbose )
> +            dprintk(VTDPREFIX,
> +                    "  RMRR region: base_addr %"PRIx64" end_address %"PRIx64"\n",
> +                    rmrru->base_address, rmrru->end_address);
> +        acpi_register_rmrr_unit(rmrru);
> +    }
> +
> +    return ret;
> +}
> +
>  static int __init
>  acpi_parse_one_rmrr(struct acpi_dmar_header *header)
>  {
> @@ -635,68 +697,10 @@ acpi_parse_one_rmrr(struct acpi_dmar_header *header)
>      ret = acpi_parse_dev_scope(dev_scope_start, dev_scope_end,
>                                 &rmrru->scope, RMRR_TYPE, rmrr->segment);
>  
> -    if ( ret || (rmrru->scope.devices_cnt == 0) )
> -        xfree(rmrru);
> +    if ( !ret && (rmrru->scope.devices_cnt != 0) )
> +        register_one_rmrr(rmrru);
>      else
> -    {
> -        u8 b, d, f;
> -        bool_t ignore = 0;
> -        unsigned int i = 0;
> -
> -        /* Skip checking if segment is not accessible yet. */
> -        if ( !pci_known_segment(rmrr->segment) )
> -            i = UINT_MAX;
> -
> -        for ( ; i < rmrru->scope.devices_cnt; i++ )
> -        {
> -            b = PCI_BUS(rmrru->scope.devices[i]);
> -            d = PCI_SLOT(rmrru->scope.devices[i]);
> -            f = PCI_FUNC(rmrru->scope.devices[i]);
> -
> -            if ( !pci_device_detect(rmrr->segment, b, d, f) )
> -            {
> -                dprintk(XENLOG_WARNING VTDPREFIX,
> -                        " Non-existent device (%04x:%02x:%02x.%u) is reported"
> -                        " in RMRR (%"PRIx64", %"PRIx64")'s scope!\n",
> -                        rmrr->segment, b, d, f,
> -                        rmrru->base_address, rmrru->end_address);
> -                ignore = 1;
> -            }
> -            else
> -            {
> -                ignore = 0;
> -                break;
> -            }
> -        }
> -
> -        if ( ignore )
> -        {
> -            dprintk(XENLOG_WARNING VTDPREFIX,
> -                "  Ignore the RMRR (%"PRIx64", %"PRIx64") due to "
> -                "devices under its scope are not PCI discoverable!\n",
> -                rmrru->base_address, rmrru->end_address);
> -            scope_devices_free(&rmrru->scope);
> -            xfree(rmrru);
> -        }
> -        else if ( base_addr > end_addr )
> -        {
> -            dprintk(XENLOG_WARNING VTDPREFIX,
> -                "  The RMRR (%"PRIx64", %"PRIx64") is incorrect!\n",
> -                rmrru->base_address, rmrru->end_address);
> -            scope_devices_free(&rmrru->scope);
> -            xfree(rmrru);
> -            ret = -EFAULT;
> -        }
> -        else
> -        {
> -            if ( iommu_verbose )
> -                dprintk(VTDPREFIX,
> -                        "  RMRR region: base_addr %"PRIx64
> -                        " end_address %"PRIx64"\n",
> -                        rmrru->base_address, rmrru->end_address);
> -            acpi_register_rmrr_unit(rmrru);
> -        }
> -    }
> +        xfree(rmrru);
>  
>      return ret;
>  }
> -- 
> 2.1.3
> 

  reply	other threads:[~2015-07-08 17:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30 23:33 [PATCH v8 0/4] iommu: add rmrr Xen command line option elena.ufimtseva
2015-06-30 23:33 ` [PATCH v8 1/4] pci: add PCI_SBDF and PCI_SEG macros elena.ufimtseva
2015-07-08 17:27   ` Konrad Rzeszutek Wilk
2015-07-09  8:10     ` Jan Beulich
2015-07-09 11:13       ` Elena Ufimtseva
2015-07-09 12:03         ` Jan Beulich
2015-06-30 23:34 ` [PATCH v8 2/4] iommu VT-d: separate rmrr addition function elena.ufimtseva
2015-07-08 17:30   ` Konrad Rzeszutek Wilk [this message]
2015-06-30 23:34 ` [PATCH v8 3/4] pci: add wrapper for parse_pci elena.ufimtseva
2015-07-08 17:32   ` Konrad Rzeszutek Wilk
2015-06-30 23:34 ` [PATCH v8 4/4] iommu: add rmrr Xen command line option for extra rmrrs elena.ufimtseva
2015-07-08 17:52   ` Konrad Rzeszutek Wilk

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=20150708173022.GB17261@l.oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=elena.ufimtseva@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=kevin.tian@intel.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    --cc=yang.z.zhang@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;
as well as URLs for NNTP newsgroup(s).