Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp796446pxy; Sun, 1 Aug 2021 02:27:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwepMv03pvfqAEoLPW+hBR3XQ9fml/Vi0H5b53WhGjLRHQCuwSIuS5r8+0eRwUfmnxNlc4k X-Received: by 2002:a05:6638:114:: with SMTP id x20mr9299011jao.118.1627810029752; Sun, 01 Aug 2021 02:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627810029; cv=none; d=google.com; s=arc-20160816; b=saf37uQOANU+qIIBjcB+sO85FX+aE9knkoZ8Xje/WGFK/37AoaQBtJpAQsSVVSm0hU O76r9b71Ou0VclJjbEmMRvUr7i91RZfDYV2J5dnltk6J7RyXQKyj4oBal341BZu/L1QH qob7df+zki7/RWysl1nCzUNK2aePPK73oRAGnNxYmjHMHmB9iOekC7J8oFL56c5rVioV rZSA2jvJ3A0BiAf8VqHQKkPuZP6tIrBDBXvtryOteCSWHw0iiJXr/HN/H7gcbMvvwxwe llZ5pzO0SNvke5k1EiRGpneBTQoamAa4nIcTIiYuWFIcL41NIhmpHh6osqA6JsZFVX5r L8vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=J9o/B//DwPC7bzFAqHVaW/CPr6Ew1m34nZ9RPkM84Po=; b=B7IwF7rkApGVGxmXeoOyIOX14d8F4nwEk55P0oNcl3WKoXUgYXL297oJYyPYwWHdct COpMHKlWqTPt1xaqeVfJ4jjWtP2mJN8rl8rRyO0H5YiIr5+fK0tfUfnlseHWKGtZTwqm gF3OpOZcnuN0/Mswc0ZL7d7u49CMqetJMaDZrfqla2VebDbT9GdIoTAuJbWV62KjYGcT +FOBZskJZdA+7r2AHM1/p13sYeY6Gh7mwc7zWxuBaG5UcYF7KLJsLUXEXzvSlykHnINH LdTWEDZejlmVus9HyqrLt8bymry2PpnXK4jvRnG0QgMssSDLI2nBxYOaBTsDUBvpgIKh 63Kw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si10899385ioo.75.2021.08.01.02.26.56; Sun, 01 Aug 2021 02:27:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231575AbhHAJYm convert rfc822-to-8bit (ORCPT + 99 others); Sun, 1 Aug 2021 05:24:42 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:39213 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbhHAJYl (ORCPT ); Sun, 1 Aug 2021 05:24:41 -0400 Received: from mail-wm1-f49.google.com ([209.85.128.49]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MOhx9-1mWtUF2haB-00Q8gW for ; Sun, 01 Aug 2021 11:24:32 +0200 Received: by mail-wm1-f49.google.com with SMTP id l4-20020a05600c1d04b02902506f89ad2dso10013936wms.1 for ; Sun, 01 Aug 2021 02:24:32 -0700 (PDT) X-Gm-Message-State: AOAM531CZBj79FSTPL6irFMiiilUTodZKf/GLi+TARpPLiC0DbI2vtSf 1kLA/MT6IDvjG13ARlNwiwl7nkig2p/SFNjz5C4= X-Received: by 2002:a05:600c:3641:: with SMTP id y1mr2673903wmq.43.1627809872298; Sun, 01 Aug 2021 02:24:32 -0700 (PDT) MIME-Version: 1.0 References: <20210801051627.78999-1-xianting.tian@linux.alibaba.com> In-Reply-To: <20210801051627.78999-1-xianting.tian@linux.alibaba.com> From: Arnd Bergmann Date: Sun, 1 Aug 2021 11:24:15 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] tty: hvc: pass DMA capable memory to put_chars() To: Xianting Tian Cc: gregkh , Jiri Slaby , Amit Shah , Arnd Bergmann , linuxppc-dev , "open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Provags-ID: V03:K1:n4+rvkXBd/PVKg1Ijf2fREdOms5QtVaA5VPpnY+9GgAsTJkSocD JTYni+qfirNeApEJ8geQkd9/iQyLudAhviTTEWcosvW+zSUP8abZUEn6evJRwpbZfNqnR2Y 6imSe+9Twi8jG3/qV4Iay8shpihqtSI1BhvSu1DzvVH+bxNQmTejQLy6NzPAu4ZywiBvReq 7qm/kFcEwA/M7qog3LGnA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:g4N/qZKZTKE=:dqEOS15OX6WNtBCecGWzIb Q1pFI7wKSj/lIpm8Ja5Y/dZ1kntOgeXTWa/rsO2MMbUNW+VVnHZ/qCh53lFD2qTpxbzqojwSp 2ytWIkyJ2ySjj8gzUVf/AnMpsbkW4nPjFj8xAlmSQmwone+y9cqRuNKRNd8T301sBd/O2r3Ji 5SMtvDyqAORh/SJSQPa+PR1rr8WSJcOMZTXH955prKZUKE+oOBtmoT0hOLqf5F5BcO6zqGgjn ewLNCz8jkhkYemjqT2PcvQvRVSVO8qOU/R6Fem66B0AGMe5PY4NkMzHU4pJZ9kEBI513VyLh/ 9KEOP1RzSwE/OKLHuMjKNjDtuwXCuiwslDcRaSBNCW/yuzMDwgRVT7TZ1G/6gZ7KU6bs07nR6 OsjrEBN3CufYXbfFVxdiPOFbFhT/qIGif5xIsOFdEJa+zfGJovN72M6QG41VXzouq+syFMlkb 9swSjHcoPqONX34PuiGofuJlWbqM2DnidpAImJbyiFcTn8/Rtl50l2x3caue3Kw3SyeFIs9G3 nOpqpE105qR7nqdqfubhKMcXUSKYQDF8AtXJis8XWmYLn+s9PDXSZalP31xa0jyRLYcliuuPr RVRHhaFFzNwSClf7+uByzesozZHBO6ER6WNnQ+aMcOC3VckytjwxdWQiKJDGIluAl1VqxTGhe 3eW2VBfZqHVCPA+NWM5ghmhVtraJFJSU4l9ZegQHXXInTVf2pXGoMaP/XY4icrGghjVkENMax df5SAp5gIWqilzdNElMn1SUS6W6yEMMe5jjSMXIv1VoZk+lfix6jZI1Y2Cx7Kccl9gLiDuKg0 DGkpuxQRzgVcYXAxWvlmcogtzPfwy4raOrSx92SL50qzyVQ28GnjW6xMN4ncFZR39+PcaQEa4 ZQYSLZxoISTORp4+a3E9Ch9FrsEPTf1Dqjsbs9Zlep7a2v8B15m4+rEG/es6EtOewyv3DyApj Y140smnio5btiatnAh4URWpcxpBS9pcf3C/pu2P/wMieuIE77KXF0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 1, 2021 at 7:16 AM Xianting Tian wrote: > Considering lock competition of hp->outbuf and the complicated logic in > hvc_console_print(), I didn’t use hp->outbuf, just allocate additional > memory(length N_OUTBUF) and append it to hp->outbuf. > For the issue in hvc_poll_put_char(), I use a static char to replace > the char in stack. While this may work, it sounds rather obscure to me, I don't think it's a good idea to append the buffer at the back. If you need a separate field besides hp->outbuf, I would make that part of the structure itself, and give it the correct alignment constraints to ensure it is in a cache line by itself. The size of this field is a compile-time constant, so I don't see a need to play tricks with pointer arithmetic. I'm not sure about the locking either: Is it possible for two CPUs to enter hvc_console_print() at the same time, or is there locking at a higher level already? It would be good to document this in the structure definition next to the field. > @@ -878,6 +885,7 @@ static void hvc_poll_put_char(struct tty_driver *driver, int line, char ch) > struct tty_struct *tty = driver->ttys[0]; > struct hvc_struct *hp = tty->driver_data; > int n; > + static char ch = ch; > > do { > n = hp->ops->put_chars(hp->vtermno, &ch, 1); This does not compile, and it's neither thread-safe nor dma safe if you get it to build by renaming the variable. Arnd