Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp88352lqb; Tue, 16 Apr 2024 09:30:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZQsmQjqjTCFbACrqv9AaCabQKlAk7Mi5XauESIrY3kZwYBgZXrsyuHNYb1kPqkTjnYnWCL+0qaby/bQUIFUhZcJxkiwzThtzy4PHCPw== X-Google-Smtp-Source: AGHT+IFT8EOk5wqs0iRj7IUY6mM5XhxA7gg5tG4Eo4v5Tkfa2jRELrixSzIgcaVOA7nEC7cw1YBw X-Received: by 2002:a05:622a:149:b0:434:4011:3cdb with SMTP id v9-20020a05622a014900b0043440113cdbmr15155884qtw.54.1713285009377; Tue, 16 Apr 2024 09:30:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713285009; cv=pass; d=google.com; s=arc-20160816; b=rwT66AURn3yif01o9COSK6oQX/o/JoCtryBSwjrUD6uJHKubE3jnne5ZIWbldqrGq1 tQzUDY22QyepPY/lqjUd4jgDSBPhCQp4I4ILTh+Ay6FCXLaNk/4epM+/72c3cGjjcXfA 0oj3ZTGsaqJkKBU4gT/PDVULOWdyBXWVtZdlaeLaQoqE7xTH9vlvF1gxyxA4dROtTakc GttyMH4Z0QpwZavbvMgQqLQdmxuATh1BXbPMOFHloV/Ft7yEJdmPNQWyOzpNpFmHZAcq PxHDeT2Hox21X4eitd76hv93OHaKk/DIS6CTX02xke5bl1PLZsHCDpw7VanSiNjTcRKG 5b2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fryuWq8aUUJjTuLOMY39ltR5o86CjDEksNCZ9CfWDGA=; fh=yisyrVYdNnNd2xNPyIz+RotZKDUVvV64nkyShsHhHYY=; b=t9TnqGd1kVZcOvSVn4hyT7WL2mUn1OtvOYnjNpSvY8URdhBLGXxfDzIU9UCnVeJj0H PeLQEccmjrl9+Qc/PPJ7XVFYdadRrfEG47Ko++zpCRFVvbuEGFxFtO91AFgeYsIyhQVK c4ZLElt5+uM2BkAYbqsflMGNcYaNGd1q5Zo0o0la073zVAKXWRqOX+3YdTC59RPFXBHE w6SVFiGA4zrx5hOFMePIUBWOr0ocjfPoNkdeMKsTC2AufNkdhU8dtAGqYO8Lubiv6QFk FY19zYzaBBJkea6b+AqzzvWWx70ttHHCG5WxG8KryL2KhkUM87BpCJs/hRaXb4TORHJI l/uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XtRzuXP9; 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-147239-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147239-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u15-20020a05622a010f00b004315fa82734si12667001qtw.494.2024.04.16.09.30.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 09:30:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147239-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XtRzuXP9; 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-147239-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147239-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0E3DF1C2191E for ; Tue, 16 Apr 2024 16:30:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B90E134411; Tue, 16 Apr 2024 16:29:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XtRzuXP9" Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 AFDF113341E; Tue, 16 Apr 2024 16:29:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713284962; cv=none; b=RXdFmao+bxP05U9dfzwGcAw8NumqmZqcTfjGUfOQjEWufJEq6zYAJpaES4ZvHtEL64wQ7vkJNnictIMuj3hcUn98S6ZRCi0Rf+XTCGpCWBeDY1wOpUfX517AF9PG8XJd0BU2fglAQgs0viHRmyFYvA25p4irFkDSzqKl02zDm4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713284962; c=relaxed/simple; bh=9TZDexUWMrvyNTz945MyInpdtCzKkNOQXNDF6Q4i2sw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H08i3afyLzC5pfg+kMafLluD1KX7NsHLYQm4bDKUYrtjkTCQjhzqZIT9BqCSbpBTjjQojWkJSC0OKFDpriZDcLqmrXELUEYPX2N2DYw3DNpm4GCr8GLF1+Xw7MwLibon09eouk5OKndIB8v1mXxfcRFe0U6Xzqe6rvGOE27dxIc= 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=XtRzuXP9; arc=none smtp.client-ip=209.85.167.52 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-f52.google.com with SMTP id 2adb3069b0e04-516d727074eso5973349e87.0; Tue, 16 Apr 2024 09:29:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713284959; x=1713889759; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fryuWq8aUUJjTuLOMY39ltR5o86CjDEksNCZ9CfWDGA=; b=XtRzuXP9J3fGiHK0yq0ZB1wcy6cwdRhqPDArY8WKbRRSbpyK+ckaPM6udK2D8+jON2 AiGzIgwdqnbtR27Ed5VaDUOtkDYm8GBoeg83FHOLAQU30yz2K9DvEVFJvUQloGNiuisc nSPL8+vU6PdyIl0wxtci3sFzhsOWzOmAt8dRNGX06Twqv/XVdkEJM+eXcLoV972G+NMI 9l2/hpgP3AsnPi5R8rkyQ6FWaag20sNgupictjodVI8upHIDV7mKQCOTrClnGEKYbts4 Nh6QLKI1vRIxSkVrHYekhrqpXbidQuYadqJthvPFcVrEYshJdnyEiwspur+6IQds29iB Js3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713284959; x=1713889759; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fryuWq8aUUJjTuLOMY39ltR5o86CjDEksNCZ9CfWDGA=; b=OJV9qkmKI3HpfSqW3nPzr7ZNXJZRBaZB7JCLeFjACv5qhTEFDu1w7t3f1yrD0mpGPH FME7nOKyJeZHOL3u7wB099F00RFzUm2VWhQ0F8IlOaqU29TD3DaijHbE6y13i2HtWlzc JoARfJ/afK9SxVfcQ1uqCgJ3ZzHctSBJJWHzWv7eOGwsz0YWV+lVeqzfQA4/iuCaF1g3 J/iUPZdpjLQuNSRdTgoV9kkKj5tldl0fykM8ZdZiHVaVuyXSGAw/6UWHM3xY+/K0BOph n1TU4SuzQaHWdhE2PzX5xJxlRbIFhH28R26LS9sjDzVVsUSD9gdGCtL8+pr7y5JmCAmO qkJQ== X-Forwarded-Encrypted: i=1; AJvYcCX8I9LlGRwKMMHBoCAtKtdIuX1/PY8Jk56dKwIg1R5IuMbleIY6ZV8dBbLP/E37A0fqbG0J/HJXL0jDodBLFjcL0uou7FoEjW9GciIolUcUcPwUaJtt23W5za55ho5ckpi1jYdG3SOn7b2nbTjqTQsep+BFrxj1X4F/7+iS61oukYQ/Jvum X-Gm-Message-State: AOJu0YwzgR8qtUYFAM1t8F+Vo2tYbM/Qp7Er7FJKlsHpKhzOiy76gfyi 8iqRDbHZfy8YyfTqzoqM9BfYu1VQnECDA4AClOR05C8buA6o38ro X-Received: by 2002:a19:3806:0:b0:518:758f:2610 with SMTP id f6-20020a193806000000b00518758f2610mr7554152lfa.48.1713284958800; Tue, 16 Apr 2024 09:29:18 -0700 (PDT) Received: from localhost (srv1.baikalchip.ru. [87.245.175.227]) by smtp.gmail.com with ESMTPSA id p8-20020a056512328800b00516d123f3b8sm1630127lfe.59.2024.04.16.09.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 09:29:18 -0700 (PDT) From: Serge Semin To: Viresh Kumar , Andy Shevchenko , Vinod Koul Cc: Serge Semin , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Greg Kroah-Hartman , Jiri Slaby , dmaengine@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] dmaengine: dw: Simplify prepare CTL_LO methods Date: Tue, 16 Apr 2024 19:28:57 +0300 Message-ID: <20240416162908.24180-4-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416162908.24180-1-fancer.lancer@gmail.com> References: <20240416162908.24180-1-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-Transfer-Encoding: 8bit Currently the CTL LO fields are calculated on the platform-specific basis. It's implemented by means of the prepare_ctllo() callbacks using the ternary operator within the local variables init block at the beginning of the block scope. The functions code currently is relatively hard to comprehend and isn't that optimal since implies four conditional statements executed and two additional local variables defined. Let's simplify the DW AHB DMA prepare_ctllo() method by unrolling the ternary operators into the normal if-else statement, dropping redundant master-interface ID variables and initializing the local variables based on the singly evaluated DMA-transfer direction check. Thus the method will look much more readable since now the fields content can be easily inferred right from the if-else branch. Provide the same update in the Intel DMA32 core driver for sake of the driver code unification. Note besides of the effects described above this update is basically a preparation before dropping the max burst encoding callback. It will require calling the burst fields calculation methods right in the prepare_ctllo() callbacks, which would have made the later function code even more complex. Signed-off-by: Serge Semin --- drivers/dma/dw/dw.c | 24 ++++++++++++++++++------ drivers/dma/dw/idma32.c | 14 ++++++++++++-- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/drivers/dma/dw/dw.c b/drivers/dma/dw/dw.c index a4862263ff14..c65438d1f1ff 100644 --- a/drivers/dma/dw/dw.c +++ b/drivers/dma/dw/dw.c @@ -67,12 +67,24 @@ static size_t dw_dma_block2bytes(struct dw_dma_chan *dwc, u32 block, u32 width) static u32 dw_dma_prepare_ctllo(struct dw_dma_chan *dwc) { struct dma_slave_config *sconfig = &dwc->dma_sconfig; - u8 smsize = (dwc->direction == DMA_DEV_TO_MEM) ? sconfig->src_maxburst : 0; - u8 dmsize = (dwc->direction == DMA_MEM_TO_DEV) ? sconfig->dst_maxburst : 0; - u8 p_master = dwc->dws.p_master; - u8 m_master = dwc->dws.m_master; - u8 dms = (dwc->direction == DMA_MEM_TO_DEV) ? p_master : m_master; - u8 sms = (dwc->direction == DMA_DEV_TO_MEM) ? p_master : m_master; + u8 sms, smsize, dms, dmsize; + + if (dwc->direction == DMA_MEM_TO_DEV) { + sms = dwc->dws.m_master; + smsize = 0; + dms = dwc->dws.p_master; + dmsize = sconfig->dst_maxburst; + } else if (dwc->direction == DMA_DEV_TO_MEM) { + sms = dwc->dws.p_master; + smsize = sconfig->src_maxburst; + dms = dwc->dws.m_master; + dmsize = 0; + } else /* DMA_MEM_TO_MEM */ { + sms = dwc->dws.m_master; + smsize = 0; + dms = dwc->dws.m_master; + dmsize = 0; + } return DWC_CTLL_LLP_D_EN | DWC_CTLL_LLP_S_EN | DWC_CTLL_DST_MSIZE(dmsize) | DWC_CTLL_SRC_MSIZE(smsize) | diff --git a/drivers/dma/dw/idma32.c b/drivers/dma/dw/idma32.c index 58f4078d83fe..3a1b12517655 100644 --- a/drivers/dma/dw/idma32.c +++ b/drivers/dma/dw/idma32.c @@ -202,8 +202,18 @@ static size_t idma32_block2bytes(struct dw_dma_chan *dwc, u32 block, u32 width) static u32 idma32_prepare_ctllo(struct dw_dma_chan *dwc) { struct dma_slave_config *sconfig = &dwc->dma_sconfig; - u8 smsize = (dwc->direction == DMA_DEV_TO_MEM) ? sconfig->src_maxburst : 0; - u8 dmsize = (dwc->direction == DMA_MEM_TO_DEV) ? sconfig->dst_maxburst : 0; + u8 smsize, dmsize; + + if (dwc->direction == DMA_MEM_TO_DEV) { + smsize = 0; + dmsize = sconfig->dst_maxburst; + } else if (dwc->direction == DMA_DEV_TO_MEM) { + smsize = sconfig->src_maxburst; + dmsize = 0; + } else /* DMA_MEM_TO_MEM */ { + smsize = 0; + dmsize = 0; + } return DWC_CTLL_LLP_D_EN | DWC_CTLL_LLP_S_EN | DWC_CTLL_DST_MSIZE(dmsize) | DWC_CTLL_SRC_MSIZE(smsize); -- 2.43.0