[Skiboot] [PATCH 5/5] hw/bt: Ask the BMC for its BT interface capabilities
Cyril Bur
cyril.bur at au1.ibm.com
Fri Oct 30 13:41:08 AEDT 2015
On Thu, 29 Oct 2015 12:32:28 +1100
Alistair Popple <alistair at popple.id.au> wrote:
> Question below, but otherwise:
>
> Acked-by: Alistair Popple <alistair at popple.id.au>
>
> On Thu, 29 Oct 2015 11:24:09 Cyril Bur wrote:
> > Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
> > ---
> > hw/bt.c | 87
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> > include/ipmi.h | 1 +
> > 2 files changed, 85 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/bt.c b/hw/bt.c
> > index 1185412..e3b16d8 100644
> > --- a/hw/bt.c
> > +++ b/hw/bt.c
> > @@ -22,6 +22,7 @@
> > #include <ipmi.h>
> > #include <bt.h>
> > #include <timer.h>
> > +#include <ipmi.h>
> >
> > /* BT registers */
> > #define BT_CTRL 0
> > @@ -108,6 +109,14 @@ struct bt_msg {
> > struct ipmi_msg ipmi_msg;
> > };
> >
> > +struct bt_caps {
> > + uint8_t num_requests;
> > + uint8_t input_buf_len;
> > + uint8_t output_buf_len;
> > + uint8_t msg_timeout;
> > + uint8_t num_retries;
> > +};
> > +
> > struct bt {
> > uint32_t base_addr;
> > struct lock lock;
> > @@ -115,7 +124,9 @@ struct bt {
> > struct timer poller;
> > bool irq_ok;
> > int queue_len;
> > + struct bt_caps caps;
> > };
> > +
> > static struct bt bt;
> >
> > static int ipmi_seq;
> > @@ -146,6 +157,66 @@ static inline void bt_assert_h_busy(void)
> > assert(rval & BT_CTRL_H_BUSY);
> > }
> >
> > +static void get_bt_caps_complete(struct ipmi_msg *msg)
> > +{
> > + /* Ignore errors, we'll fallback to using the defaults, no big deal */
> > +
> > + if (msg->data[0] == 0) {
> > + prerror("Got illegal BMC BT capability\n");
> > + goto out;
> > + }
> > +
> > + if (msg->data[3] + 1 != BT_FIFO_LEN) {
> > + prerror("Got a input buffer len (%d) cap which differs from
> the default\n",
> > + msg->data[3]);
> > + goto out;
> > + }
> > +
> > + if (msg->data[4] + 1 != BT_FIFO_LEN) {
> > + prerror("Got a output buffer len (%d) cap which differs from
> the default\n",
> > + msg->data[4]);
> > + goto out;
> > + }
> > +
> > + memcpy(&bt.caps, msg->data, sizeof(struct bt_caps));
> > +
> > + /*
> > + * IPMI Spec says that the value for buffer sizes are:
> > + * "the largest value allowed in first byte"
> > + * Therefore we want to add one to what we get
> > + */
> > + bt.caps.input_buf_len++;
> > + bt.caps.output_buf_len++;
> > + prlog(PR_DEBUG, "BMC BT capabilities received:\n");
> > + prlog(PR_DEBUG, "buffer sizes: %d input %d output\n",
> > + bt.caps.input_buf_len, bt.caps.output_buf_len);
> > + prlog(PR_DEBUG, "number of requests: %d\n", bt.caps.num_requests);
> > + prlog(PR_DEBUG, "msg timeout: %d max retries: %d\n",
> > + bt.caps.msg_timeout, bt.caps.num_retries);
> > +
> > +out:
> > + ipmi_free_msg(msg);
> > +}
> > +
> > +static void get_bt_caps(void)
> > +{
> > +
> > + struct ipmi_msg *bmc_caps;
> > + /*
> > + * Didn't sent a message, now is a good time to ask the BMC for its
> > + * capabilities.
> > + */
> > + bmc_caps = ipmi_mkmsg(IPMI_DEFAULT_INTERFACE, IPMI_GET_BT_CAPS,
> > + get_bt_caps_complete, NULL, NULL, 0, sizeof(struct
> bt_caps));
> > + if (!bmc_caps)
> > + prerror("Couldn't create BMC BT capabilities msg\n");
> > +
> > + if (bmc_caps && ipmi_queue_msg(bmc_caps))
> > + prerror("Couldn't enqueue request for BMC BT capabilities\n");
> > +
> > + /* Ignore errors, we'll fallback to using the defaults, no big deal */
>
> Does the default IPMI error handler print anything to the console? Given AMI
> doesn't support this command we want to make sure we don't litter the console
> with spurious error messages.
>
Good point, I'm not sure I'd tested with debugging turned off anyway. Here is
the log of me booting normally, looks fine to me.
[16045277550,5] SkiBoot skiboot-5.1.8-46-gfb92eb7 starting...
[16045283958,5] initial console log level: memory 7, driver 5
[16045286733,6] CPU: P8 generation processor(max 8 threads/core)
[16045289169,7] CPU: Boot CPU PIR is 0x0068 PVR is 0x004d0200
[16045291903,7] CPU: Initial max PIR set to 0x1fff
[16045645304,5] OPAL table: 0x300a7040 .. 0x300a74a0, branch table: 0x30002000
[16045649983,5] FDT: Parsing fdt @0xff00000
[16046205453,5] XSCOM: chip 0x0 at 0x3fc0000000000 [P8 DD2.0]
[16046216593,6] XSTOP: XSCOM addr = 0x2010c82, FIR bit = 31
[16046219644,6] MFSI 0:0: Initialized
[16046221530,6] MFSI 0:2: Initialized
[16046223450,6] MFSI 0:1: Initialized
[16046271903,5] LPC: Bus on chip 0 PCB_Addr=0xb0020
[16046282259,5] LPC: Default bus on chip 0
[16046311520,6] MEM: parsing reserved memory from node /ibm,hostboot/reserved-memory [16046322316,7] HOMER: Init chip 0
[16046324703,7] PBA BAR0 : 0x0000000ffd800000
[16046327148,7] PBA MASK0: 0x0000000000300000
[16046329526,7] HOMER Image at 0xffd800000 size 4MB
[16046332843,7] PBA BAR2 : 0x4000000ffda00000
[16046335331,7] PBA MASK2: 0x0000000000000000
[16046337626,7] SLW Image at 0xffda00000 size 1MB
[16046340731,7] PBA BAR3 : 0x0000000fff800000
[16046343103,7] PBA MASK3: 0x0000000000700000
[16046345364,7] OCC Common Area at 0xfff800000 size 8MB
[16046379514,5] PLAT: Fixing up PSI BAR on chip 0 BAR=3fffe80000001
[16046417711,7] AST: PNOR LPC offset: 0x0e000000
[16046520005,5] PLAT: Using virtual UART
[16079525049,5] PLAT: Detected Palmetto platform
[16080717546,5] CENTAUR: Found centaur for chip 0x0 channel 1
[16081158170,5] CENTAUR: FSI host: 0x0 cMFSI0 port 2
[16081989231,5] PSI[0x000]: Found PSI bridge [working=1, active=0]
[873121187,5] BT: Interface initialized, IO 0x00e4
[1436720268,4] SLW: HB-provided idle states property found
[1436834028,5] NVRAM: Size is 576 KB
[1627757454,3] NVRAM: Layout appears sane
[1627840970,5] CAPI: Preloading ucode 200ea
[1627961095,5] FLASH: Queueing preload of 2/200ea
[1628040552,5] FLASH: Queueing preload of 0/0
[1628065256,7] FFS: Partition map size: 0x1000
[1629421993,5] FLASH: Queueing preload of 1/0
[1630000727,7] FLASH: CAPP partition has ECC
[1630604818,5] Chip 0 Found PBCQ2 at /xscom at 3fc0000000000/pbcq at 2012800
[1631320255,5] Chip 0 Found PBCQ1 at /xscom at 3fc0000000000/pbcq at 2012400
[1632132664,7] FLASH: flash subpartition eyecatcher CAPP
[1632134442,7] FLASH: flash found subpartition: 1 size: 36432 offset 4096
[1633596361,5] Chip 0 Found PBCQ0 at /xscom at 3fc0000000000/pbcq at 2012000
[1634967106,3] PHB#0002: Base location code not found !
[1697074600,3] PHB#0001: Base location code not found !
[1757523663,3] PHB#0000: Base location code not found !
[1817913135,5] PCI: Resetting PHBs...
[2432459267,5] PCI: Probing slots...
[3149834020,5] PHB#0000:00:00.0 [ROOT] 1014 03dc R:00 C:060400 B:01..01
[3150567823,5] PHB#0000:01:00.0 [LGCY] 10de 13ba R:a2 C:030000 ( vga)
[3151412729,5] PHB#0000:01:00.1 [EP ] 10de 0fbc R:a1 C:040300
(multimedia-device) [3152152513,5] PHB#0001:00:00.0 [ROOT] 1014 03dc R:00
C:060400 B:01..07 [3153012234,5] PHB#0001:01:00.0 [SWUP] 10b5 8718 R:aa
C:060400 B:02..07 [3153716223,5] PHB#0001:02:01.0 [SWDN] 10b5 8718 R:aa
C:060400 B:03..04 [3154390175,5] PHB#0001:03:00.0 [ETOX] 1a03 1150 R:03
C:060400 B:04..04 [3156012304,5] PHB#0001:04:00.0 [PCID] 1a03 2000 R:30
C:030000 ( vga) [3156804239,5] PHB#0001:02:02.0 [SWDN] 10b5 8718 R:aa
C:060400 B:05..05 [3157543957,5] PHB#0001:05:00.0 [EP ] 104c 8241 R:02
C:0c0330 ( usb-xhci) [3158370150,5] PHB#0001:02:03.0 [SWDN] 10b5 8718 R:aa
C:060400 B:06..06 [3159080150,5] PHB#0001:06:00.0 [EP ] 14e4 1656 R:10
C:020000 ( ethernet) [3160383263,5] PHB#0001:06:00.1 [EP ] 14e4 1656 R:10
C:020000 ( ethernet) [3165348953,5] PHB#0001:02:04.0 [SWDN] 10b5 8718 R:aa
C:060400 B:07..07 [3166632887,5] PHB#0001:07:00.0 [LGCY] 1b4b 9235 R:11
C:010601 ( sata) [3167397726,5] PHB#0002:00:00.0 [ROOT] 1014 03dc R:00
C:060400 B:01..01 [3168135205,5] PHB#0002:01:00.0 [EP ] 1014 0477 R:01
C:120000 ( device) [3169424204,5] Releasing unused memory:
[3169540639,5] ibm,firmware-heap: 2262376/13631488 used
[3170237036,5] ibm,firmware-allocs-memory at 0: 6554112/67750592512 used
[3181607423,5] Reserved regions:
[3182263690,5] 0x000ffd800000..000ffdbfffff : ibm,homer-image at ffd800000
[3182996671,5] 0x000ffd700000..000ffd7fffff : ibm,hbrt-vpd-image at ffd700000
[3183763147,5] 0x000ffd6f0000..000ffd6fffff : ibm,hbrt-target-image at ffd6f0000
[3184606022,5] 0x000ffd4e0000..000ffd6effff : ibm,hbrt-code-image at ffd4e0000
[3186045607,5] 0x000fff800000..000fffffffff : ibm,occ-common-area at fff800000
[3186934061,5] 0x000031c00000..000031dbffff : ibm,firmware-stacks
[3187699643,5] 0x000031000000..000031bfffff : ibm,firmware-data
[3188429060,5] 0x000030300000..000030ffffff : ibm,firmware-heap
[3189138493,5] 0x000030000000..0000302fffff : ibm,firmware-code
[3189923169,5] 0x000039c00000..00003a2401ff : ibm,firmware-allocs-memory at 0
[3190719941,5] INIT: Waiting for kernel...
[3224098430,3] BT seq 0x09 netfn 0x18 cmd 0x24: Retry sending message
[6729940816,3] FLASH: No ROOTFS partition
[6730636422,5] INIT: Kernel loaded, size: 15728640 bytes (0 = unknown preload)
[6730823510,5] INIT: 64-bit LE kernel discovered
[6730897057,5] INIT: 64-bit kernel entry at 0x20010000
[6731484796,3] OCC: Chip: 0 PState table is not valid
[6732107897,3] OCC: Initialization on all chips did not complete(timed out)
[6737764358,5] Free space in HEAP memory regions:
[6737858941,5] Region ibm,firmware-heap free: 10864656
[6737997860,5] Region ibm,firmware-allocs-memory at 0 free: 1125840
[6738662383,5] Total free: 11990496
[6739229166,5] INIT: Starting kernel at 0x20010000, fdt at 0x305294f0 (size
0x84d7) [6909947544,3] OPAL: Trying a CPU re-init with flags: 0x2
> > +}
> > +
> > static inline bool bt_idle(void)
> > {
> > uint8_t bt_ctrl = bt_inb(BT_CTRL);
> > @@ -220,7 +291,7 @@ static void bt_clear_fifo(void)
> > {
> > int i;
> >
> > - for (i = 0; i < BT_FIFO_LEN; i++)
> > + for (i = 0; i < bt.caps.input_buf_len; i++)
> > bt_outb(0xff, BT_HOST2BMC);
> > }
> >
> > @@ -321,7 +392,7 @@ static void bt_expire_old_msg(uint64_t tb)
> >
> > bt_msg = list_top(&bt.msgq, struct bt_msg, link);
> >
> > - if (bt_msg && bt_msg->tb > 0 && (bt_msg->tb + BT_MSG_TIMEOUT) < tb) {
> > + if (bt_msg && bt_msg->tb > 0 && (bt_msg->tb + bt.caps.msg_timeout) <
> tb) {
> > if (bt_msg->send_count < BT_MAX_SEND_COUNT) {
> > /* A message timeout is usually due to the BMC
> > clearing the H2B_ATN flag without actually
> > @@ -391,7 +462,6 @@ static void bt_send_and_unlock(void)
> > }
> >
> > unlock(&bt.lock);
> > - return;
> > }
> >
> > static void bt_poll(struct timer *t __unused, void *data __unused,
> > @@ -554,6 +624,13 @@ void bt_init(void)
> > const struct dt_property *prop;
> > uint32_t irq;
> >
> > + /* Set sane capability defaults */
> > + bt.caps.num_requests = 1;
> > + bt.caps.input_buf_len = BT_FIFO_LEN;
> > + bt.caps.output_buf_len = BT_FIFO_LEN;
> > + bt.caps.msg_timeout = BT_MSG_TIMEOUT;
> > + bt.caps.num_retries = 1;
> > +
> > /* We support only one */
> > n = dt_find_compatible_node(dt_root, NULL, "ipmi-bt");
> > if (!n)
> > @@ -595,5 +672,9 @@ void bt_init(void)
> > irq = dt_prop_get_u32(n, "interrupts");
> > bt_lpc_client.interrupts = LPC_IRQ(irq);
> > lpc_register_client(dt_get_chip_id(n), &bt_lpc_client);
> > +
> > + /* Enqueue an IPMI message to ask the BMC about its BT capabilities */
> > + get_bt_caps();
> > +
> > prlog(PR_DEBUG, "BT: Using LPC IRQ %d\n", irq);
> > }
> > diff --git a/include/ipmi.h b/include/ipmi.h
> > index 99a9094..6aeacb0 100644
> > --- a/include/ipmi.h
> > +++ b/include/ipmi.h
> > @@ -117,6 +117,7 @@
> > #define IPMI_GET_MESSAGE_FLAGS IPMI_CODE(IPMI_NETFN_APP,
> 0x31)
> > #define IPMI_GET_MESSAGE IPMI_CODE(IPMI_NETFN_APP, 0x33)
> > #define IPMI_READ_EVENT IPMI_CODE(IPMI_NETFN_APP,
> 0x35)
> > +#define IPMI_GET_BT_CAPS IPMI_CODE(IPMI_NETFN_APP, 0x56)
> > #define IPMI_SET_SENSOR_READING IPMI_CODE(IPMI_NETFN_SE, 0x30)
> >
> > /* AMI OEM comamnds. AMI uses NETFN 0x3a and 0x32 */
> >
>
More information about the Skiboot
mailing list