Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp883779lqb; Wed, 17 Apr 2024 13:42:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbjectN6hIur86ZPCVgomNbMIc1W0WL1Fqf67MAINq3bVpRJCUivTfSHbODMEEVUhI595BdaHOCSjOHlH7bDITs7e1eHNxh8mZ647OHw== X-Google-Smtp-Source: AGHT+IE9l/bZDdIKKGvpuzlGh2yfosKUULGH9SmA/EwhhORQ4RQG9PbHTmhwbmBQdTvQkIySSZf4 X-Received: by 2002:a05:6870:a903:b0:235:458e:c8cf with SMTP id eq3-20020a056870a90300b00235458ec8cfmr887396oab.14.1713386577046; Wed, 17 Apr 2024 13:42:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713386577; cv=pass; d=google.com; s=arc-20160816; b=J6bz/7PHrMtaw3CsaOsO7SJBT1ZbKLKewsfupI9gDgiw+bVCw+l55g8756yrX6eMzq hwY0kKz37W0VevEoRLxxlRWoRWDnkH+xV4NeU4EWpuHTR/ZBuq5EV39WAMzAAUC9a1xq vTiAeUl1wId7EeE4zqoNNihDvzyfl1R8kDoagkaD0Aq8h+eBx7+vyeq2/ETy5zEezhYS WuLvLZYLQ4Dd9oIi3Q3Ns6j3pzQtxY2BCWIZhs4lKjcbeDknAGk7IfTI2XAYMJgMTQrF JTWMOrKgHEt2ng0rENJL6fHoRhp4CYneGEpDCMB2UJleR+s7rDsv91PcQvoAeNStZM34 eKrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=R38L2lZrS+14WeM7ceh5Hp6+XyP4h36lYdwyJTOLv3o=; fh=D6GqkAs+NoKCHlBiw86amcJzjSzGRz/XQJJcABUDye4=; b=b8dtzUasmGxCHg7IDyEMo7qhQYl7MF9iSlgoG8IPb04k1fqj2Ue9FNFMDv3I2tgtjx QKCzwf0IRpllp2LZMRqLlRGzjjPtfU6q5kLgaFqDzhre129E0yJaVjeKh0/nAqqMUmg+ izGyj7qphK+H+eKoZc9LCaI/vrJGfBRJSwjkGvjAn9zKwAz0tLume39dM9WQilVXR1on 4qsTmriYtqLd8nnLQz8nWqc39kKLFg8Gy+Rl5+tMNy0lCRqC2g0thx7rlDfmltZH09Vn UXvBLMJtnkE8koMT5+88KFkf61L7ZGQ+iLbGdZUSJtCGyJB940sF/jHYGyZVouZ1l4wq 8wHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XVesQ+Zh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-149194-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149194-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j28-20020a634a5c000000b005f072090d58si27425pgl.743.2024.04.17.13.42.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 13:42:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149194-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XVesQ+Zh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-149194-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149194-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9434728A677 for ; Wed, 17 Apr 2024 20:35:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B3DA41C62; Wed, 17 Apr 2024 20:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XVesQ+Zh" Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94E7B22324; Wed, 17 Apr 2024 20:35:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713386145; cv=none; b=Vxz+b73Zhnhdii2WxJmaRFWjzjsPRzviLP6+V0A+jCX7W1lBUQCuhYTnaRmCz6rY9n3HdI9gyqW/P0BL8eyAVQtLoEcwNtL9byV9UuCoLkrD8cyEnffqNdl/FMHbzuUVumx/SRPQj4nXskPMCMkvVTlbi3kDLUs3KPa2nlBOJY4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713386145; c=relaxed/simple; bh=I6EJ1mP91iVz//8c5ia8HdkNztwtT3dmN/fNeMRppuQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QBgnekPicobWahSMr11geql/xWKQWrzYl3P5LXwsPJ9pvR/RzFaYrzdgN6TI53sRdgS0U5ua3DiDOxHnxE1Ew8mJ+ewq0uUrX/FdGRcUqSkr9YSYtL/CG0JNIw9/MBz4jzKiQcivSeYk6x4EbFaZllxMpOSERmonsiF4yVVVVvU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XVesQ+Zh; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-516d4d80d00so115906e87.0; Wed, 17 Apr 2024 13:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713386142; x=1713990942; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=R38L2lZrS+14WeM7ceh5Hp6+XyP4h36lYdwyJTOLv3o=; b=XVesQ+Zhs/VE2C1W/74tIZerg5ra8xzGQlkZZUZt9vFyGHpz2IjUfU7ys5suniB99a T/X+jX3t2dpduabwYEAgQxDRR56cNFcNs2Bzn9twcSxmOyduLcnNH76VGfXPv38+yssv b6/W2ZMWu5e5OMyWzqeqfYiPP124Bw8lwPMb382kBoJe2t2fLNafD0sWG2KNb+O80+t3 JzoAWrHXjpwpyjxlz5fPQouBp07bI44oAMMerW7i6wSFMp6OwP1SGDfN0+EFGg5Cxp2j tLBqDYOrjal32/l/OorWoDt5RTsi/TRTGELpXEYEZd2QInsjqfjujxvC1RLBBl7QC6rE DB0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713386142; x=1713990942; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=R38L2lZrS+14WeM7ceh5Hp6+XyP4h36lYdwyJTOLv3o=; b=CTVtrCFj+H3O9Hgu4n/nXQEeMu9eAnuKrvWVHwMZpXsu2jCjSadcHVz8hmWPtV+F4q uRgDmoVi2UvMRY7jeDmLsK9950Bvtq5Rr1wYB65DSXe7wG4k8rsqcKq/dtRivDxX64ga W2PIYbdz3yPCYEVxXCBsquRT1iG8ZMm3w91/ul0WOBNP47iTQp0vAzksR1vsoU4QwF00 I4bedHUBCJ3Dm8z1U0gKSL0tyAgBRj2MtyKElrOJSX7BvviRCCCcQDrZ11QL7IYZbIpN CxHoe36bLsShuxJHqJQUqzyiBiUvgIn0NrPOJGFRooDtrk+O0X554OiV39IgwD3PjRq5 IbmQ== X-Forwarded-Encrypted: i=1; AJvYcCXtdEg9drOqnKQ4QKIFkB5TXu1F6pJDqrbX9do2HR5sp+Wy7mvhIbDhW4eqW3egZLux0DQG6YLVieoGkUx1lWRVdF10ZqjW/VRhIhVFh4OWWJpZW25/mXCNKRY/6PsfWW7AybaXZzz3l0jUK5tnbXhCe5LZYeccXll7lDePIgZXlO0TmobA X-Gm-Message-State: AOJu0YzraD+PLP1py/m0Y+T6NENP5sH3iIat9duB9/iibsAWR6oBc/Je nd76XPNMd+2GBRBICB0vU3b5bD1IjaqHBXwECuWQk/1DQi5sJV0Y9BzFd/jX X-Received: by 2002:ac2:456c:0:b0:515:d038:5548 with SMTP id k12-20020ac2456c000000b00515d0385548mr224508lfm.31.1713386141501; Wed, 17 Apr 2024 13:35:41 -0700 (PDT) Received: from mobilestation.baikal.int (srv1.baikalchip.ru. [87.245.175.227]) by smtp.gmail.com with ESMTPSA id q13-20020ac2514d000000b00515d1dfab34sm2056041lfd.81.2024.04.17.13.35.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 13:35:41 -0700 (PDT) Date: Wed, 17 Apr 2024 23:35:39 +0300 From: Serge Semin To: Andy Shevchenko Cc: Viresh Kumar , Vinod Koul , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , Greg Kroah-Hartman , Jiri Slaby , dmaengine@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] dmaengine: dw: Simplify max-burst calculation procedure Message-ID: References: <20240416162908.24180-1-fancer.lancer@gmail.com> <20240416162908.24180-5-fancer.lancer@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Apr 16, 2024 at 10:11:58PM +0300, Andy Shevchenko wrote: > On Tue, Apr 16, 2024 at 07:28:58PM +0300, Serge Semin wrote: > > In order to have a more coherent DW AHB DMA slave configuration method > > let's simplify the source and destination channel max-burst calculation > > procedure: > > > > 1. Create the max-burst verification method as it has been just done for > > the memory and peripheral address widths. Thus the DWC DMA slave config > > dwc_config() method > > ? Right. I'll just directly refer to the dwc_config() method here. > > > method will turn to a set of the verification methods execution. > > > > 2. Since both the generic DW AHB DMA and Intel DMA32 engines support the > > "i" in iDMA 32-bit stands for "integrated", so 'Intel iDMA 32-bit' Ok. Thanks for clarification. > > > power-of-2 bursts only, then the specified by the client driver max-burst > > values can be converted to being power-of-2 right in the max-burst > > verification method. > > > > 3. Since max-burst encoded value is required on the CTL_LO fields > > calculation stage, the encode_maxburst() callback can be easily dropped > > from the dw_dma structure meanwhile the encoding procedure will be > > executed right in the CTL_LO register value calculation. > > > > Thus the update will provide the next positive effects: the internal > > DMA-slave config structure will contain only the real DMA-transfer config > > value, which will be encoded to the DMA-controller register fields only > > when it's required on the buffer mapping; the redundant encode_maxburst() > > callback will be dropped simplifying the internal HW-abstraction API; > > DWC-config method will look more readable executing the verification > > dwc_config() method > > ? Ok. > > > functions one-by-one. > > ... > > > +static void dwc_verify_maxburst(struct dma_chan *chan) > > It's inconsistent to the rest of _verify methods. It doesn't verify as it > doesn't return anything. Make it int or rename the function. Making it int won't make much sense since currently the method doesn't imply returning an error status. IMO using "verify" was ok, but since you don't see it suitable please suggest a better alternative. mend, fix, align? > > > +{ > > + struct dw_dma_chan *dwc = to_dw_dma_chan(chan); > > + > > + dwc->dma_sconfig.src_maxburst = > > + clamp(dwc->dma_sconfig.src_maxburst, 1U, dwc->max_burst); > > + dwc->dma_sconfig.dst_maxburst = > > + clamp(dwc->dma_sconfig.dst_maxburst, 1U, dwc->max_burst); > > + > > + dwc->dma_sconfig.src_maxburst = > > + rounddown_pow_of_two(dwc->dma_sconfig.src_maxburst); > > + dwc->dma_sconfig.dst_maxburst = > > + rounddown_pow_of_two(dwc->dma_sconfig.dst_maxburst); > > +} > > ... > > > static int dwc_verify_p_buswidth(struct dma_chan *chan) > > - reg_burst = rounddown_pow_of_two(dwc->dma_sconfig.src_maxburst); > > + reg_burst = dwc->dma_sconfig.src_maxburst; > > Seems you have a dependency, need a comment below that maxburst has to be > "verified" [whatever] first. Ok. > > ... > > > +static inline u8 dw_dma_encode_maxburst(u32 maxburst) > > +{ > > + /* > > + * Fix burst size according to dw_dmac. We need to convert them as: > > + * 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3. > > + */ > > + return maxburst > 1 ? fls(maxburst) - 2 : 0; > > +} > > Split these moves to another preparatory patch. Ok. -Serge(y) > > -- > With Best Regards, > Andy Shevchenko > >