Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1613893
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!news.mixmin.net!aioe.org!news.servidellagleba.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Olliver Schinagl <o.schinagl@ultimaker.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] serial: Do not treat the IIR register as a bitfield |
| Date | Fri, 31 Mar 2017 13:30:02 +0200 |
| Message-ID | <tr2UG-3Xe-41@gated-at.bofh.it> (permalink) |
| References | <tqqPn-2sY-3@gated-at.bofh.it> <tqBB7-23k-1@gated-at.bofh.it> <tqC4a-2hn-21@gated-at.bofh.it> <tqJ5D-7vN-5@gated-at.bofh.it> |
| X-Original-To | Theodore Ts'o <tytso@mit.edu>, Vignesh R <vigneshr@ti.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jslaby@suse.com>, Laxman Dewangan <ldewangan@nvidia.com>, Stephen Warren <swarren@wwwdotorg.org>, Thierry Reding <thierry.reding@gmail.com>, Alexandre Courbot <gnurou@gmail.com>, "David S . Miller" <davem@davemloft.net>, "dev@linux-sunxi.org" <dev@linux-sunxi.org>, Ed Blake <ed.blake@imgtec.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Alexander Sverdlin <alexander.sverdlin@nokia.com>, Yegor Yefremov <yegorslists@googlemail.com>, Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com>, Kefeng Wang <wangkefeng.wang@huawei.com>, Heikki Krogerus <heikki.krogerus@linux.intel.com>, Heiko Stuebner <heiko@sntech.de>, Jason Uy <jason.uy@broadcom.com>, Douglas Anderson <dianders@chromium.org>, Peter Hurley <peter@hurleysoftware.com>, Tony Lindgren <tony@atomide.com>, Thor Thayer <tthayer@opensource.altera.com>, David Lechner <david@lechnology.com>, Jan Kiszka <jan.kiszka@siemens.com>, "linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>, "sparclinux@vger.kernel.org" <sparclinux@vger.kernel.org> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultimaker-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=PB0p7nGr/THolOJBqJ39ShueEE5yl7X2JlD6yneoex8=; b=MJ1kyoa90S+zNwRQGGsOu+k/hy9UwzxnIpuNU7QMtevUVF87s/MZOovz0j57wDMbtY wGS+wxOgivFy7gLjDXtX2GY/M5sSqkmeu2OAGqZEp5Ou8H9Yb+gINSdytFOTZgkRpmdi eH4I/NvosK5tdWv54HuqKAybEqNwlAymyuYSOuJEG4Iq4o7cUvJhsuOpGk6nuxZ5xhY2 iNxjx4ezE0a4BGffdPMa9N7hTsjpIPeQEC3Gn/mTpFtvCEtfOSuMyiOtOhRhasji8egv vpjCnhqcMw9Lx3+p3gfCWRhK/HHZZOJe/fmoDZg48/8sqB84EVfTOUyneNzPSei3sQfP fyrA== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=PB0p7nGr/THolOJBqJ39ShueEE5yl7X2JlD6yneoex8=; b=HZiECnRgsRPLNKUgcaovBbKC0bj54xdb/sn/PS8u0CckzKfADMML9DWU5OHRds3Czf P8J+HhfZwG0Ggl0+/jViOh+HFqL3cON7B+j2wdtLKTa4+S7XsMyB8VE7DZpMg1DDSSy4 hRj/+qD/YdhFtIcA3sVV1G+OJQRTWs4nisgUFezpYehjYtXThWF5MXvDP01uut9f5xUw 4VgYLxD5SUJeKRyYQE6S7QLR7/1ECGjz2k3g9tcJyoiDnc/MBoKpu21aoiZ+qF1TalJI r+2nvCSRXDFrcr6imPfP73Ge6ITkQiZJ4Q8JFf9xjl6GYEzPIONLbWS7O3ypgEYjfQLa YRhw== |
| X-Gm-Message-State | AFeK/H2eA09iJcbJatVSnydiI0aa08ImM9uh0cOCrp0ZYZ8MKBUl/IYRm8TZMOoaTZD2jZSB |
| X-Received | by 10.223.163.28 with SMTP id c28mr2319233wrb.186.1490959682929; Fri, 31 Mar 2017 04:28:02 -0700 (PDT) |
| X-Google-Original-From | Olliver Schinagl <oliver@schinagl.nl> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| 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 | 61 |
| Organization | linux.* mail to news gateway |
| X-Original-Date | Fri, 31 Mar 2017 13:28:00 +0200 |
| X-Original-Message-ID | <03bb0be7-3534-0f26-9f79-061282331186@schinagl.nl> |
| X-Original-References | <20170329184431.6226-1-oliver@schinagl.nl> <6be65e8b-eea4-08ed-0b30-5c0608764a83@ti.com> <D694FA74-1F31-4B57-8858-2DBE8DE57D45@schinagl.nl> <20170330141153.mvxa6iqj72hnhlu3@thunk.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1613893 |
Show key headers only | View raw
Hey Ted, On 30-03-17 16:11, Theodore Ts'o wrote: > While you're fixing this, there's a bug in samples/vfio-mdev/mtty.c: > > u8 ier = mdev_state->s[index].uart_reg[UART_IER]; > *buf = 0; > > mutex_lock(&mdev_state->rxtx_lock); > /* Interrupt priority 1: Parity, overrun, framing or break */ > if ((ier & UART_IER_RLSI) && mdev_state->s[index].overrun) > *buf |= UART_IIR_RLSI; > > /* Interrupt priority 2: Fifo trigger level reached */ > if ((ier & UART_IER_RDI) && > (mdev_state->s[index].rxtx.count == > mdev_state->s[index].intr_trigger_level)) > *buf |= UART_IIR_RDI; > > /* Interrupt priotiry 3: transmitter holding register empty */ > if ((ier & UART_IER_THRI) && > (mdev_state->s[index].rxtx.head == > mdev_state->s[index].rxtx.tail)) > *buf |= UART_IIR_THRI; > > /* Interrupt priotiry 4: Modem status: CTS, DSR, RI or DCD */ > if ((ier & UART_IER_MSI) && > (mdev_state->s[index].uart_reg[UART_MCR] & > (UART_MCR_RTS | UART_MCR_DTR))) > *buf |= UART_IIR_MSI; > > /* bit0: 0=> interrupt pending, 1=> no interrupt is pending */ > if (*buf == 0) > *buf = UART_IIR_NO_INT; > > It's treating the UART_IIR_* fields as a bitmask which is bad enough, > but in the "Interrupt priority 4" case, UART_IIR_MSI is zero, so > "*buf |= UART_IIR_MSI" is a no-op. And in the case where the modem > status interrupt is the only thing set, *buf will be 0, and UART_IIR_NO_INT > gets set erroneously. > > So this is another example of the bug of trying to treat the > UART_IIR_* fields as a bitmask.... > > Yes, it's only sample code, but best fix it now before it gets copied > elsewhere and metastisizes. :-) Yeah, I notice that a lot of the code I modified in this patch was either copy pasted or 'inspired by'. So having bad examples around is really bad as you state! Additionally the friendly build bot reminded me there are other subsystems that do this as well, so I'll update the patch to get those too and this one too. Olliver > > - Ted > >
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] serial: Do not treat the IIR register as a bitfield Olliver Schinagl <oliver@schinagl.nl> - 2017-03-29 20:50 +0200
Re: [PATCH] serial: Do not treat the IIR register as a bitfield Vignesh R <vigneshr@ti.com> - 2017-03-30 08:20 +0200
Re: [PATCH] serial: Do not treat the IIR register as a bitfield Olliver Schinagl <oliver@schinagl.nl> - 2017-03-30 08:50 +0200
Re: [PATCH] serial: Do not treat the IIR register as a bitfield Vignesh R <vigneshr@ti.com> - 2017-03-30 10:10 +0200
Re: [PATCH] serial: Do not treat the IIR register as a bitfield Olliver Schinagl <oliver@schinagl.nl> - 2017-03-30 17:50 +0200
Re: [PATCH] serial: Do not treat the IIR register as a bitfield Theodore Ts'o <tytso@mit.edu> - 2017-03-30 16:20 +0200
Re: [PATCH] serial: Do not treat the IIR register as a bitfield Olliver Schinagl <o.schinagl@ultimaker.com> - 2017-03-31 13:30 +0200
Re: [PATCH] serial: Do not treat the IIR register as a bitfield Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-03-30 12:10 +0200
Re: [PATCH] serial: Do not treat the IIR register as a bitfield Olliver Schinagl <o.schinagl@ultimaker.com> - 2017-03-31 16:00 +0200
Re: [PATCH] serial: Do not treat the IIR register as a bitfield Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-03-31 16:50 +0200
Re: [PATCH] serial: Do not treat the IIR register as a bitfield kbuild test robot <lkp@intel.com> - 2017-03-30 14:20 +0200
csiph-web