From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98AB6C4338F for ; Thu, 12 Aug 2021 08:08:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7148260FED for ; Thu, 12 Aug 2021 08:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234944AbhHLII2 (ORCPT ); Thu, 12 Aug 2021 04:08:28 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:58651 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbhHLII0 (ORCPT ); Thu, 12 Aug 2021 04:08:26 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0UiluUWC_1628755679; Received: from B-LB6YLVDL-0141.local(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0UiluUWC_1628755679) by smtp.aliyun-inc.com(127.0.0.1); Thu, 12 Aug 2021 16:07:59 +0800 Subject: Re: [PATCH v4 1/2] tty: hvc: pass DMA capable memory to put_chars() To: Arnd Bergmann Cc: gregkh , Jiri Slaby , Amit Shah , Omar Sandoval , linuxppc-dev , "open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE" , Linux Kernel Mailing List , Guo Ren References: <20210806030138.123479-1-xianting.tian@linux.alibaba.com> <20210806030138.123479-2-xianting.tian@linux.alibaba.com> From: Xianting TIan Message-ID: Date: Thu, 12 Aug 2021 16:07:58 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2021/8/6 下午10:51, Arnd Bergmann 写道: > On Fri, Aug 6, 2021 at 5:01 AM Xianting Tian > wrote: >> @@ -163,6 +155,13 @@ static void hvc_console_print(struct console *co, const char *b, >> if (vtermnos[index] == -1) >> return; >> >> + list_for_each_entry(hp, &hvc_structs, next) >> + if (hp->vtermno == vtermnos[index]) >> + break; >> + >> + c = hp->c; >> + >> + spin_lock_irqsave(&hp->c_lock, flags); > The loop looks like it might race against changes to the list. It seems strange > that the print function has to actually search for the structure here. > > It may be better to have yet another array for the buffer pointers next to > the cons_ops[] and vtermnos[] arrays. > >> +/* >> + * These sizes are most efficient for vio, because they are the >> + * native transfer size. We could make them selectable in the >> + * future to better deal with backends that want other buffer sizes. >> + */ >> +#define N_OUTBUF 16 >> +#define N_INBUF 16 >> + >> +#define __ALIGNED__ __attribute__((__aligned__(sizeof(long)))) > I think you need a higher alignment for DMA buffers, instead of sizeof(long), > I would suggest ARCH_DMA_MINALIGN. As some ARCH(eg, x86, riscv) doesn't define ARCH_DMA_MINALIG, so i think it 's better remain the code unchanged, I will send v5 patch soon. > > Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2410AC4338F for ; Thu, 12 Aug 2021 08:08:53 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5592360FED for ; Thu, 12 Aug 2021 08:08:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5592360FED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GlfTZ5jy0z3cPT for ; Thu, 12 Aug 2021 18:08:50 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.57; helo=out30-57.freemail.mail.aliyun.com; envelope-from=xianting.tian@linux.alibaba.com; receiver=) Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GlfT16hwMz2yfZ for ; Thu, 12 Aug 2021 18:08:17 +1000 (AEST) X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R161e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e04426; MF=xianting.tian@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0UiluUWC_1628755679; Received: from B-LB6YLVDL-0141.local(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0UiluUWC_1628755679) by smtp.aliyun-inc.com(127.0.0.1); Thu, 12 Aug 2021 16:07:59 +0800 Subject: Re: [PATCH v4 1/2] tty: hvc: pass DMA capable memory to put_chars() To: Arnd Bergmann References: <20210806030138.123479-1-xianting.tian@linux.alibaba.com> <20210806030138.123479-2-xianting.tian@linux.alibaba.com> From: Xianting TIan Message-ID: Date: Thu, 12 Aug 2021 16:07:58 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiri Slaby , Amit Shah , gregkh , Linux Kernel Mailing List , "open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE" , Guo Ren , linuxppc-dev , Omar Sandoval Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 在 2021/8/6 下午10:51, Arnd Bergmann 写道: > On Fri, Aug 6, 2021 at 5:01 AM Xianting Tian > wrote: >> @@ -163,6 +155,13 @@ static void hvc_console_print(struct console *co, const char *b, >> if (vtermnos[index] == -1) >> return; >> >> + list_for_each_entry(hp, &hvc_structs, next) >> + if (hp->vtermno == vtermnos[index]) >> + break; >> + >> + c = hp->c; >> + >> + spin_lock_irqsave(&hp->c_lock, flags); > The loop looks like it might race against changes to the list. It seems strange > that the print function has to actually search for the structure here. > > It may be better to have yet another array for the buffer pointers next to > the cons_ops[] and vtermnos[] arrays. > >> +/* >> + * These sizes are most efficient for vio, because they are the >> + * native transfer size. We could make them selectable in the >> + * future to better deal with backends that want other buffer sizes. >> + */ >> +#define N_OUTBUF 16 >> +#define N_INBUF 16 >> + >> +#define __ALIGNED__ __attribute__((__aligned__(sizeof(long)))) > I think you need a higher alignment for DMA buffers, instead of sizeof(long), > I would suggest ARCH_DMA_MINALIGN. As some ARCH(eg, x86, riscv) doesn't define ARCH_DMA_MINALIG, so i think it 's better remain the code unchanged, I will send v5 patch soon. > > Arnd