Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1593269

Re: [PATCH 1/5] PCI: add resizeable BAR infrastructure v2

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Andy Shevchenko <andy.shevchenko@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/5] PCI: add resizeable BAR infrastructure v2
Date Mon, 06 Mar 2017 13:30:02 +0100
Message-ID <thZW2-880-11@gated-at.bofh.it> (permalink)
References <thZjk-7C0-7@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=BPsou3miR6W6dHgY6NBDv8XaWCv+OVGx3UO58eH7Rfk=; b=HhVbC/zEn0TjicQcq5ADsOp6TP2xJvO2hnMXEyg54BXYAQNTmVn96+JQFD1+7mwDyU u83Rdx8wjcJvfv/oYFkKYBSEQagvMPbs50h3/b5FLug5endcVGff7TkaHI1csyjchxKZ pUff4HcOD37Ru2qyjI0B8cjlX0v+VOOOhewZlfSka+gBjyNeIEQc9ha6bPG0qJdLyVee 4SnXhENWG8tCt4+IcV4bXYe1R91qH6eoWfWilXqEQRFqmRsVf8RV7X9oTO8Rc853wMlM 4BQpEr02Yc7fAqvGnLGW6/LSVBiv3cndK7w2a39xy6UgwzWoQ7SzFVkhqL5fqb0GdPay wrwA==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=BPsou3miR6W6dHgY6NBDv8XaWCv+OVGx3UO58eH7Rfk=; b=Ldvb7coBJ6YtnOJCAkkhu6S5w3n4IDVg2z1XPYH5tYAVBOowEwXq5+cuL7L9p2gGx+ S4rvtXVZtrp3otMUpJ/cvCR9MlfToR7YbKdYPo+5pZjSx3O4qRQkKpveOwmgBHhaWo1v yCDiXF0yb3PC/mo5HR0CoETPhk6mhON20wQfu/7y+/E7MoYIU4sHsyrJy7Us5TgyxLpL F0YW0IM/hN3IIX9eNmgYk+gQX+TYsUqAuF+18CZzc+4J/JYirySgcNuiouuJDF7hRUUx VQ4qpd1qAF1wNXhMmahwa2brdclewmHTTRy4M0K0GQ0eW68JupeSQ+kVyFFEyVVv0L+I PkMA==
X-Gm-Message-State AMke39lXxZMrnh3v5iz3RSiNmuRnRm7UL1q7yyskxD1mCW7Yh6C4JVWlRrxXJenO0ZshgP1pIfhKxtW1BuK+Rw==
X-Received by 10.200.0.25 with SMTP id a25mr2238656qtg.199.1488802824733; Mon, 06 Mar 2017 04:20:24 -0800 (PST)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 102
Organization linux.* mail to news gateway
X-Original-Cc "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>, dri-devel@lists.freedesktop.org, Platform Driver <platform-driver-x86@vger.kernel.org>, amd-gfx@lists.freedesktop.org, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
X-Original-Date Mon, 6 Mar 2017 14:20:24 +0200
X-Original-Message-ID <CAHp75Vet-gb_mXA2Uwdai+G2AeJ4p10eTjgmC2h5Gnmosd69WA@mail.gmail.com>
X-Original-References <1488800428-2854-1-git-send-email-deathsimple@vodafone.de>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1593269

Show key headers only | View raw


On Mon, Mar 6, 2017 at 1:40 PM, Christian König <deathsimple@vodafone.de> wrote:
> From: Christian König <christian.koenig@amd.com>
>
> Just the defines and helper functions to read the possible sizes of a BAR and
> update it's size.
>
> See https://pcisig.com/sites/default/files/specification_documents/ECN_Resizable-BAR_24Apr2008.pdf.
>
> v2: provide read helper as well

Commit message left away the explanation at which point this API might
be useful and how it fits in managed resources model?

>  /**
> + * pci_rbar_get_sizes - get possible sizes for BAR

Why not simple pci_rbar_get_possible_sizes() ?

> +u32 pci_rbar_get_sizes(struct pci_dev *pdev, int bar)
> +{
> +       int pos, nbars;
> +       u32 ctrl, cap;
> +       int i;
> +
> +       pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR);
> +       if (!pos)

> +               return 0x0;

return 0;

> +
> +       pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
> +       nbars = (ctrl & PCI_REBAR_CTRL_NBAR_MASK) >> PCI_REBAR_CTRL_NBAR_SHIFT;
> +

> +       for (i = 0; i < nbars; ++i, pos += 8) {

8 is defined somewhere in the spec? (Yes, I understand that is just 64
bits shift)

> +               int bar_idx;
> +
> +               pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
> +               bar_idx = (ctrl & PCI_REBAR_CTRL_BAR_IDX_MASK) >>
> +                               PCI_REBAR_CTRL_BAR_IDX_SHIFT;
> +               if (bar_idx != bar)
> +                       continue;
> +
> +               pci_read_config_dword(pdev, pos + PCI_REBAR_CAP, &cap);
> +               return (cap & PCI_REBAR_CTRL_SIZES_MASK) >>
> +                       PCI_REBAR_CTRL_SIZES_SHIFT;
> +       }
> +

> +       return 0x0;

return 0;

> +/**
> + * pci_rbar_get_size - get the current size of a BAR

pci_rbar_get_current_size() ?

> +/**
> + * pci_rbar_set_size - set a new size for a BAR
> + * @dev: PCI device
> + * @bar: BAR to set size to

> + * @size: new size as defined in the spec.

 * @size: bitmasked value of new size (bit 0=1MB, ..., bit 19=512G)

?

It will briefly get a clue without reading either spec or long description.

> + *
> + * Set the new size of a BAR as defined in the spec (0=1MB, 19=512GB).
> + * Returns true if resizing was successful, false otherwise.
> + */

> +bool pci_rbar_set_size(struct pci_dev *pdev, int bar, int size)

I would return int and error code. It would be better in the future
and seems in alignment with above.

> +{
> +       int pos, nbars;
> +       u32 ctrl;
> +       int i;

All ints are unsigned?

-- 
With Best Regards,
Andy Shevchenko

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/5] PCI: add resizeable BAR infrastructure v2 Christian König <deathsimple@vodafone.de> - 2017-03-06 12:50 +0100
  [PATCH 3/5] x86/PCI: Enable a 64bit BAR on AMD Family 15h (Models 30h-3fh) Processors Christian König <deathsimple@vodafone.de> - 2017-03-06 12:50 +0100
  [PATCH 4/5] drm/amdgpu: fix printing the doorbell BAR info Christian König <deathsimple@vodafone.de> - 2017-03-06 12:50 +0100
    Re: [PATCH 4/5] drm/amdgpu: fix printing the doorbell BAR info Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-03-06 13:10 +0100
      Re: [PATCH 4/5] drm/amdgpu: fix printing the doorbell BAR info Christian König <deathsimple@vodafone.de> - 2017-03-06 13:30 +0100
  [PATCH 2/5] PCI: add functionality for resizing resources Christian König <deathsimple@vodafone.de> - 2017-03-06 12:50 +0100
  [PATCH 5/5] drm/amdgpu: resize VRAM BAR for CPU access Christian König <deathsimple@vodafone.de> - 2017-03-06 12:50 +0100
    Re: [PATCH 5/5] drm/amdgpu: resize VRAM BAR for CPU access Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-03-06 13:10 +0100
      Re: [PATCH 5/5] drm/amdgpu: resize VRAM BAR for CPU access Christian König <deathsimple@vodafone.de> - 2017-03-06 13:40 +0100
  Re: [PATCH 1/5] PCI: add resizeable BAR infrastructure v2 Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-03-06 13:30 +0100
    Re: [PATCH 1/5] PCI: add resizeable BAR infrastructure v2 Christian König <deathsimple@vodafone.de> - 2017-03-13 10:50 +0100

csiph-web