From 3394fabbd17ad7263feeb0f4ae593056237f0647 Mon Sep 17 00:00:00 2001 From: Jae Hyun Yoo Date: Tue, 30 Jul 2019 13:01:58 -0700 Subject: [PATCH] peci: add a temporary workaround To cover a PECI issue, this commit makes PECI driver block all PECI commands when PLTRST_N signal is 0. Also, it adds 'use_wa' module parameter for platforms that don't have the PLTRST_N gpio input so that the WA can be disabled through the module parameter. This is a temporary workaround. Signed-off-by: Jae Hyun Yoo --- drivers/peci/busses/peci-aspeed.c | 11 +++++++++++ drivers/peci/peci-core.c | 11 +++++++++++ include/linux/peci.h | 1 + 3 files changed, 23 insertions(+) diff --git a/drivers/peci/busses/peci-aspeed.c b/drivers/peci/busses/peci-aspeed.c index 8a0dd40730cc..76394ab32854 100644 --- a/drivers/peci/busses/peci-aspeed.c +++ b/drivers/peci/busses/peci-aspeed.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -445,6 +446,16 @@ static int aspeed_peci_probe(struct platform_device *pdev) if (ret) goto err_put_adapter_dev; + priv->adapter->pltrst_pin = of_get_gpio(pdev->dev.of_node, 0); + if (gpio_is_valid(priv->adapter->pltrst_pin)) { + ret = devm_gpio_request(&pdev->dev, priv->adapter->pltrst_pin, + "peci-aspeed"); + if (ret < 0) { + priv->adapter->pltrst_pin = -1; + dev_err(&pdev->dev, "error requesting pltrst gpio\n"); + } + } + ret = peci_add_adapter(priv->adapter); if (ret) goto err_put_adapter_dev; diff --git a/drivers/peci/peci-core.c b/drivers/peci/peci-core.c index b99ba788a032..2e3b9a0c83e9 100644 --- a/drivers/peci/peci-core.c +++ b/drivers/peci/peci-core.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -190,6 +191,11 @@ static int peci_aw_fcs(struct peci_xfer_msg *msg, int len, u8 *aw_fcs) return 0; } +/* Temporary WA */ +static bool use_wa __read_mostly = true; +module_param_named(use_wa, use_wa, bool, 0644); +MODULE_PARM_DESC(use_wa, "flag for enabling of WA"); + static int __peci_xfer(struct peci_adapter *adapter, struct peci_xfer_msg *msg, bool do_retry, bool has_aw_fcs) { @@ -197,6 +203,11 @@ static int __peci_xfer(struct peci_adapter *adapter, struct peci_xfer_msg *msg, u8 aw_fcs; int ret; + /* Temporary WA */ + if (use_wa && gpio_is_valid(adapter->pltrst_pin) && + gpio_get_value(adapter->pltrst_pin) == 0) + return -EAGAIN; + /* * In case if adapter uses DMA, check at here whether tx and rx buffers * are DMA capable or not. diff --git a/include/linux/peci.h b/include/linux/peci.h index 6fc424dc2a73..e589cb258a2a 100644 --- a/include/linux/peci.h +++ b/include/linux/peci.h @@ -44,6 +44,7 @@ struct peci_adapter { struct peci_xfer_msg *msg); u32 cmd_mask; bool use_dma; + int pltrst_pin; }; static inline struct peci_adapter *to_peci_adapter(void *d) -- 2.7.4