From patchwork Wed Jul 3 03:16:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1126586 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JUWetAws"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dmV72HbYz9s3Z; Wed, 3 Jul 2019 13:16:30 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hiVkt-0000L8-Lf; Wed, 03 Jul 2019 03:16:23 +0000 Received: from mail-pg1-f195.google.com ([209.85.215.195]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1hiVks-0000Kp-5G for kernel-team@lists.ubuntu.com; Wed, 03 Jul 2019 03:16:22 +0000 Received: by mail-pg1-f195.google.com with SMTP id f25so406921pgv.10 for ; Tue, 02 Jul 2019 20:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=IR6fcUG06EWClceAfpAryuMNFCKUvd3iMsrwAxyEXN0=; b=JUWetAwsmmgwy8KUdOSRFiWdo0GWVgUmE3iTBzuqcMMLWhxd3Q2xN1RAMfPjZ3nKgV ZBH/WxTnp8dPn9Ln9orkuoLxLKwczo9tLhRmCJDrEOPhM4C8x93wvggR6anDA7TqNbPa CkbPfN+HS1BAZY4LB4fV9Pay20V8q7woPSoA9Bfg5wNoudDvu5B+zOdTxjP+h3FP3XbU nxRs8i5zAcgy+epoNrMnC2A/b6HM7NrApcXifZmWyzz4R+ewq0R8F9sdg2VVTvluDH3r Koa0+UO0isSkFPGCP0gdH2YwNvxWqTvZZJcS5tFQOHBPNU5HkftR8U12MobwmD/kvY92 ikLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=IR6fcUG06EWClceAfpAryuMNFCKUvd3iMsrwAxyEXN0=; b=BYk7jV6s9niauIFCfys2PGnX4Oyb94SGZoaGy9nN533o94P+pSrpHMj9QpCep3Vlzr Cd2wiz83G/Qbw90AET9ofl/9xFfCCFgoGABDaVobLmJ5170ZELdNXMcUZBFqVNR73nvs j7h9KAiyMQXpbTKiW5vG5pQhzrE50n/ejBD+JWss0mbNR/vNlK9UarXvTOXWkFX58wYI UQ8VG5l++/jizRFF1Lhr5oIjxbaCxdhMrT2e8RoXDZg5X7LtWZuaFSvimiVHiLYyFbbS VnzKckBmXyUMwzZKv9ro3m++G2yeDg1PsiPTs02MRoW8NDUAq53OqxwgiAA76+FEMwMV CQHQ== X-Gm-Message-State: APjAAAU4LNaSqbZcL1z/NlOLjItacV3H3WUvQNaIo+9LE/GZjr0WCTSB K3nXeyqJ5E3qGl5deEGPIFIUcqdE X-Google-Smtp-Source: APXvYqwwaaEE1iV5wsmAXbLRDukfS42KEQQdZ5Fxe1LL6WzD3fO2QXFJnnPAn98GjKr2cZ1iDWh8+w== X-Received: by 2002:a63:3f48:: with SMTP id m69mr33498458pga.17.1562123780024; Tue, 02 Jul 2019 20:16:20 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id m16sm479878pfd.127.2019.07.02.20.16.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2019 20:16:19 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/2][SRU][D][OEM-OSP1-B] i2c: i2c-designware-platdrv: Cleanup setting of the adapter number Date: Wed, 3 Jul 2019 11:16:12 +0800 Message-Id: <20190703031615.1704-2-acelan.kao@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703031615.1704-1-acelan.kao@canonical.com> References: <20190703031615.1704-1-acelan.kao@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hans de Goede BugLink: https://bugs.launchpad.net/bugs/1835150 i2c-designware-platdrv assumes that if the pdev has an apci-companion it should use a dynamic adapter-nr and otherwise it will use pdev->id as adapter-nr. Before this commit the setting of the adapter.nr was somewhat convoluted, in the acpi_companion case it was set from dw_i2c_acpi_configure, in the non acpi_companion case it was set from dw_i2c_set_fifo_size based on tx_fifo_depth not being set yet indicating that dw_i2c_acpi_configure was not executed. This cleans this up, directly setting the adapter-nr from dw_i2c_plat_probe for both cases. Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Acked-by: Jarkko Nikula Signed-off-by: Wolfram Sang (cherry picked from commit 77f3381a83c2f66daeb6719a1191a87280d57f62) Signed-off-by: AceLan Kao --- drivers/i2c/busses/i2c-designware-platdrv.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index ead5e7de3e4d..30529839cbd2 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -86,7 +86,6 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev) struct i2c_timings *t = &dev->timings; u32 ss_ht = 0, fp_ht = 0, hs_ht = 0, fs_ht = 0; - dev->adapter.nr = -1; dev->tx_fifo_depth = 32; dev->rx_fifo_depth = 32; @@ -219,7 +218,7 @@ static void i2c_dw_configure_slave(struct dw_i2c_dev *dev) dev->mode = DW_IC_SLAVE; } -static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev, int id) +static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev) { u32 param, tx_fifo_depth, rx_fifo_depth; @@ -233,7 +232,6 @@ static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev, int id) if (!dev->tx_fifo_depth) { dev->tx_fifo_depth = tx_fifo_depth; dev->rx_fifo_depth = rx_fifo_depth; - dev->adapter.nr = id; } else if (tx_fifo_depth >= 2) { dev->tx_fifo_depth = min_t(u32, dev->tx_fifo_depth, tx_fifo_depth); @@ -358,13 +356,17 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000); } - dw_i2c_set_fifo_size(dev, pdev->id); + dw_i2c_set_fifo_size(dev); adap = &dev->adapter; adap->owner = THIS_MODULE; adap->class = I2C_CLASS_DEPRECATED; ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); adap->dev.of_node = pdev->dev.of_node; + if (has_acpi_companion(&pdev->dev)) + adap->nr = -1; + else + adap->nr = pdev->id; dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_SMART_PREPARE | From patchwork Wed Jul 3 03:16:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1126588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qnIUOCqN"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dmV74Jw7z9sN4; Wed, 3 Jul 2019 13:16:30 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hiVkw-0000MG-TT; Wed, 03 Jul 2019 03:16:26 +0000 Received: from mail-pf1-f177.google.com ([209.85.210.177]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1hiVkv-0000LL-82 for kernel-team@lists.ubuntu.com; Wed, 03 Jul 2019 03:16:25 +0000 Received: by mail-pf1-f177.google.com with SMTP id r7so472105pfl.3 for ; Tue, 02 Jul 2019 20:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=rRgxDRCdn0xA2upwgYXnPJYG6bKJoN6zbiNlLGfYTFo=; b=qnIUOCqNObl/NeVkRykCZXQA7yG7uDeelzpCGC0Q9Pakg8UOhG6sfrLQ3nR2JmUsBK liN7QDk8gZOHXVWzyPrBTyF7XSqcCpt/3uIDT4wNSXJ2qpI3CkQIy607fcoBZ1j11LUd UNNc1PjtZSDtZSNNpCD95r9RZw0+c7mqwAwiz8AbKpHJqd8QyHZeQQISKOkSxzaKsL1R TofVig43m8r5XJwj247sXHjCsYmNvILauQi94KmeQtH413GWqIJcqlaAT7E5gPQdiN8Z aUJ5rmp2Eplo2R2XT8AtM2xuhI06eIzLrxIefrqGenlzWN24Isi9EvlRk6NfiSWNDLtZ MaRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=rRgxDRCdn0xA2upwgYXnPJYG6bKJoN6zbiNlLGfYTFo=; b=moh7/ZpJHBKAgV0WiwcUCUZ0tBy+N0PF4toq3UvIKyhuI5IIVzlLzM8/GYW1wZ9T2P aYZtloqVHa0xQb010cft1w3cG64APkdjA6jk2QrzANFlnPvH1RVutheb7PnK/qtunLwS vG8PwH8qy95WMs5x+PX05P13Bl/FIjdkCc1xOveP4rUMS1tRbolalLuaznTzhja8hdI2 RhRSVPsCn68/NFp4oMjK34neiAu4dYUbsTNRPCqHi7ZHxEShKxbwY5O2L/5tCuwKlU6S Hk5fmAzUNMPb9EkwWDhWRbRPEdPAU2N/qfIcKKg1hJv1xL0Jxacaq2Mq9ydNlwoNWu4M /kNA== X-Gm-Message-State: APjAAAUf4zMFy0+z53Lu21MOkjxA47J8dNNzCvzTz+abfNLvwYxMzHIQ 2KogubOEJJreQC5JuGlavc7cOgb2 X-Google-Smtp-Source: APXvYqw5t9yZzUdCo0XMD9Up1FW6DY42vIcEBHt0wiRMEv1ru+/9SgOSq2sda40/z+vOD+9WKdN1fQ== X-Received: by 2002:a63:221c:: with SMTP id i28mr30598015pgi.114.1562123783444; Tue, 02 Jul 2019 20:16:23 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id s66sm507012pgs.39.2019.07.02.20.16.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2019 20:16:22 -0700 (PDT) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/2][SRU][D][OEM-OSP1-B] i2c: i2c-designware-platdrv: Always use a dynamic adapter number Date: Wed, 3 Jul 2019 11:16:13 +0800 Message-Id: <20190703031615.1704-3-acelan.kao@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703031615.1704-1-acelan.kao@canonical.com> References: <20190703031615.1704-1-acelan.kao@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hans de Goede BugLink: https://bugs.launchpad.net/bugs/1835150 Before this commit the i2c-designware-platdrv assumes that if the pdev has an apci-companion it should use a dynamic adapter-nr and it sets adapter->nr to -1, otherwise it will use pdev->id as adapter->nr. There are 3 ways how platform_device-s to which i2c-designware-platdrv will bind can be instantiated: 1) Through of / devicetree 2) Through ACPI enumeration 3) Explicitly instantiated through platform_device_create + add 1) In case of devicetree-instantiation the drivers/of code always sets pdev->id to PLATFORM_DEVID_NONE, which is -1 so in this case both paths to set adapter->nr end up doing the same thing. 2) In case of ACPI instantiation the device will always have an ACPI-companion, so we are already using dynamic adapter-nrs. 3) There are 2 places manually instantiating a designware_i2c platform_dev: drivers/mfd/intel_quark_i2c_gpio.c drivers/mfd/intel-lpss.c In the intel_quark_i2c_gpio.c case pdev->id is always 0, so switching to dynamic adapter-nrs here could lead to the bus-number no longer being stable, but the quark X1000 only has 1 i2c-controller, which will also be assigned bus-number 0 when using dynamic adapter-nrs. In the intel-lpss.c case intel_lpss_probe() is called from either intel-lpss-acpi.c in which case there always is an ACPI-companion, or from intel-lpss-pci.c. In most cases devices handled by intel-lpss-pci.c also have an ACPI-companion, so we use a dynamic adapter-nr. But in some cases the ACPI-companion is missing and we would use pdev->id (allocated from intel_lpss_devid_ida). Devices which use the intel-lpss-pci.c code typically have many i2c busses, so using pdev->id in this case may lead to a bus-number conflict, triggering a WARN(id < 0, "couldn't get idr") in i2c-core-base.c causing an oops an the adapter registration to fail. So in this case using non dynamic adapter-nrs is actually undesirable. One machine on which this oops was triggering is the Apollo Lake based Acer TravelMate Spin B118. TL;DR: Switching to always using dynamic adapter-numbers does not make any difference in most cases and in the one case where it does make a difference the behavior change is desirable because the old behavior caused an oops. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1687065 Signed-off-by: Hans de Goede Acked-by: Andy Shevchenko Acked-by: Jarkko Nikula Signed-off-by: Wolfram Sang (cherry picked from commit cd86d1403bb4c80e443d736b2a692cbf68a9f471) Signed-off-by: AceLan Kao --- drivers/i2c/busses/i2c-designware-platdrv.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 30529839cbd2..416f89b8f881 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -363,10 +363,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) adap->class = I2C_CLASS_DEPRECATED; ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); adap->dev.of_node = pdev->dev.of_node; - if (has_acpi_companion(&pdev->dev)) - adap->nr = -1; - else - adap->nr = pdev->id; + adap->nr = -1; dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_SMART_PREPARE |