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


Groups > linux.kernel > #1705162

Re: [PATCH] thunderbolt: icm: Remove Apple check for Alpine Ridge

Path csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod
From Kai-Heng Feng <kai.heng.feng@canonical.com>
Newsgroups linux.kernel
Subject Re: [PATCH] thunderbolt: icm: Remove Apple check for Alpine Ridge
Date Mon, 07 Aug 2017 09:30:01 +0200
Message-ID <ubKE9-5de-1@gated-at.bofh.it> (permalink)
References <ubKb9-4Nl-27@gated-at.bofh.it> <ubKb9-4Nl-25@gated-at.bofh.it> <ubKkN-56m-5@gated-at.bofh.it>
X-Original-To Mika Westerberg <mika.westerberg@linux.intel.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5HvonxGjA+e6AqqwUk1U4mA4VwAssw8y40yAZNzTD0w=; b=k+DNqpSNVa6zKcPPqVBJdIx21UhL8xuJVVb+xtnmMT29Ef/k1yzM4eqkOypPShIt2u IpEM5eyfX9AGsY2bVrDXCVfSYY9CiG76r/QsyYXVIA/AcHVPJ7FjJ1yFC2de5RppPgQE mbRpb0K0nXR+p9crjpTOlwNi1tlaa+GPWDetm0XU+FPkrfRihn4lEIw1pJa0ZM6rtI2G PMwHUwvkJ3/2Mr3dRW5ZBDZ4Vrg4dJ1pyWPKEl55PfzA4+0R2YOZES1aLW4hHz3kebs/ cBpFEBz5w1KT8fXiDT9A/h+EXrXVQ4bJL5KGjSoCbstNDFYSegXq8pg7mX2E5F7rKbUh mDGw==
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; bh=5HvonxGjA+e6AqqwUk1U4mA4VwAssw8y40yAZNzTD0w=; b=hL+F25d1uyGheSkSdkrssQrXUmFG91ms/ZTX+MCeAkq4JKSp6dVeYMG0BxHFmR0eIP FubjeSHP0IhvOwpPgM97Pbk17TIhh/7TVfqIYn0UoNnzhDn3Dtcg+KzqD3MvNQ7/CQao dBZzsBn6ktZ8YDntAgZrt2DxhhM0hA/mB7Ty/dMB2hAOO+bkdy/efn02vzonXWMPzAgQ HqARemX7WU8cl0IqFXSBmhEkKQf0tZ82ahpwPcyCCud0OYGtxUB9tA61as+HDWBcTtG5 VmbC51vGV+hop3QuZX7y8KPXj5EvIQrfbPHyrJdgNTfTR/kL2TLDBJ8KFK2IJ/vMH8kH JsAw==
X-Gm-Message-State AHYfb5ioqPXS8v9sZM3IFUnYxuSNMVMT876rJQKOFlpTX+1cG2cXCM3L Yi5JZWzqP8FGm58JRp5hCpK5tDaLSVvM
X-Received by 10.28.141.205 with SMTP id p196mr756wmd.58.1502090440810; Mon, 07 Aug 2017 00:20:40 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset="UTF-8"
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 83
Organization linux.* mail to news gateway
X-Original-Cc LKML <linux-kernel@vger.kernel.org>, andreas.noever@gmail.com, michael.jamet@intel.com, yehezkel.bernat@intel.com
X-Original-Date Mon, 7 Aug 2017 15:20:40 +0800
X-Original-Message-ID <CAAd53p6M0Vh7xsa3UfEV_fmnbXfyi9knUQvbNRkhGdZrHtSEMQ@mail.gmail.com>
X-Original-References <20170807044912.18146-1-kai.heng.feng@canonical.com> <CAAd53p5c+MHuviVjEi0=oJ0eEE3atW181PsHpCjfqnhtHBy=GA@mail.gmail.com> <20170807070254.GL2369@lahna.fi.intel.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1705162

Show key headers only | View raw


On Mon, Aug 7, 2017 at 3:02 PM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> On Mon, Aug 07, 2017 at 02:50:49PM +0800, Kai-Heng Feng wrote:
>> On Mon, Aug 7, 2017 at 12:49 PM, Kai-Heng Feng
>> <kai.heng.feng@canonical.com> wrote:
>> > In icm_ar_is_supported(), icm->upstream_port will be uninitialized if
>> > the hardware is not an Apple one.
>> >
>> > The uninitialized icm->upstream_port will later be dereferenced in
>> > pcie2cio_write(), causes a NULL pointer dereference issue.
>> >
>> > Commit f67cf491175a ("thunderbolt: Add support for Internal Connection
>> > Manager (ICM)") states that all Alpine Ridge will use ICM, so I guess
>> > it's safe to remove the Apple check.
>
> Yes, Alpine Ridge uses ICM but on Apple systems we need to additional
> steps to get it up and running. That's why the check is there. So no it
> cannot be removed.

If that's the case, it probably should be like this:

diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c
index bdaac1ff00a5..95c255996ff0 100644
--- a/drivers/thunderbolt/icm.c
+++ b/drivers/thunderbolt/icm.c
@@ -888,9 +888,11 @@ static int icm_driver_ready(struct tb *tb)
        struct icm *icm = tb_priv(tb);
        int ret;

-       ret = icm_firmware_init(tb);
-       if (ret)
-               return ret;
+       if (is_apple()) {
+               ret = icm_firmware_init(tb);
+               if (ret)
+                       return ret;
+       }

        if (icm->safe_mode) {
                tb_info(tb, "Thunderbolt host controller is in safe mode.\n");
---

The uninitialized icm->upstream_port, will be used at here:

icm_firmware_init()
  icm_firmware_start()
    icm_firmware_reset()
      pcie2cio_write()
        pci_write_config_dword(pdev, vnd_cap + PCIE2CIO_WRDATA, data);

> Is there an actual issue you are trying to solve here?

Yes, please take a look at [1].

Although both the patch I sent and the diff above still failed to
probe the device
But there are no more NULL pointer dereference.

[1]  https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1708043/comments/11

>
>> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>> > ---
>> >  drivers/thunderbolt/icm.c | 7 -------
>> >  1 file changed, 7 deletions(-)
>> >
>> > diff --git a/drivers/thunderbolt/icm.c b/drivers/thunderbolt/icm.c
>> > index bdaac1ff00a5..2ab25aac5446 100644
>> > --- a/drivers/thunderbolt/icm.c
>> > +++ b/drivers/thunderbolt/icm.c
>> > @@ -514,13 +514,6 @@ static bool icm_ar_is_supported(struct tb *tb)
>> >         struct icm *icm = tb_priv(tb);
>> >
>> >         /*
>> > -        * Starting from Alpine Ridge we can use ICM on Apple machines
>> > -        * as well. We just need to reset and re-enable it first.
>> > -        */
>> > -       if (!is_apple())
>> > -               return true;
>> > -
>> > -       /*
>
> How did you test this?

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


Thread

Re: [PATCH] thunderbolt: icm: Remove Apple check for Alpine Ridge Kai-Heng Feng <kai.heng.feng@canonical.com> - 2017-08-07 09:00 +0200
  Re: [PATCH] thunderbolt: icm: Remove Apple check for Alpine Ridge Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-08-07 09:10 +0200
    Re: [PATCH] thunderbolt: icm: Remove Apple check for Alpine Ridge Kai-Heng Feng <kai.heng.feng@canonical.com> - 2017-08-07 09:30 +0200
      Re: [PATCH] thunderbolt: icm: Remove Apple check for Alpine Ridge Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-08-07 10:00 +0200
        Re: [PATCH] thunderbolt: icm: Remove Apple check for Alpine Ridge Kai-Heng Feng <kai.heng.feng@canonical.com> - 2017-08-07 10:10 +0200
          Re: [PATCH] thunderbolt: icm: Remove Apple check for Alpine Ridge Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-08-07 10:10 +0200

csiph-web