Message ID | 20220407223629.21487-1-ricardo.martinez@linux.intel.com |
---|---|
Headers | show |
Series | net: wwan: t7xx: PCIe driver for MediaTek M.2 modem | expand |
On 4/12/2022 5:04 AM, Ilpo Järvinen wrote: > On Thu, 7 Apr 2022, Ricardo Martinez wrote: > >> From: Haijun Liu <haijun.liu@mediatek.com> >> >> Control Port implements driver control messages such as modem-host >> handshaking, controls port enumeration, and handles exception messages. >> >> The handshaking process between the driver and the modem happens during >> the init sequence. The process involves the exchange of a list of >> supported runtime features to make sure that modem and host are ready >> to provide proper feature lists including port enumeration. Further >> features can be enabled and controlled in this handshaking process. >> >> Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> >> Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> >> Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >> Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >> >> >From a WWAN framework perspective: >> Reviewed-by: Loic Poulain <loic.poulain@linaro.org> >> >> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> >> +static int t7xx_prepare_device_rt_data(struct t7xx_sys_info *core, struct device *dev, >> + void *data) >> +{ >> + struct feature_query *md_feature = data; >> + struct mtk_runtime_feature *rt_feature; >> + unsigned int i, rt_data_len = 0; >> + struct sk_buff *skb; >> + >> + /* Parse MD runtime data query */ >> + if (le32_to_cpu(md_feature->head_pattern) != MD_FEATURE_QUERY_ID || >> + le32_to_cpu(md_feature->tail_pattern) != MD_FEATURE_QUERY_ID) { >> + dev_err(dev, "Invalid feature pattern: head 0x%x, tail 0x%x\n", >> + le32_to_cpu(md_feature->head_pattern), >> + le32_to_cpu(md_feature->tail_pattern)); >> + return -EINVAL; >> + } >> + >> + for (i = 0; i < FEATURE_COUNT; i++) { >> + if (FIELD_GET(FEATURE_MSK, md_feature->feature_set[i]) != >> + MTK_FEATURE_MUST_BE_SUPPORTED) >> + rt_data_len += sizeof(*rt_feature); >> + } >> + >> + skb = t7xx_ctrl_alloc_skb(rt_data_len); >> + if (!skb) >> + return -ENOMEM; >> + >> + rt_feature = skb_put(skb, rt_data_len); >> + memset(rt_feature, 0, rt_data_len); >> + >> + /* Fill runtime feature */ >> + for (i = 0; i < FEATURE_COUNT; i++) { >> + u8 md_feature_mask = FIELD_GET(FEATURE_MSK, md_feature->feature_set[i]); >> + >> + if (md_feature_mask == MTK_FEATURE_MUST_BE_SUPPORTED) >> + continue; >> + >> + rt_feature->feature_id = i; >> + if (md_feature_mask == MTK_FEATURE_DOES_NOT_EXIST) >> + rt_feature->support_info = md_feature->feature_set[i]; >> + >> + rt_feature++; >> + } >> + >> + /* Send HS3 message to device */ >> + t7xx_port_send_ctl_skb(core->ctl_port, skb, CTL_ID_HS3_MSG, 0); >> + return 0; >> +} >> + >> +static int t7xx_parse_host_rt_data(struct t7xx_fsm_ctl *ctl, struct t7xx_sys_info *core, >> + struct device *dev, void *data, int data_length) >> +{ >> + enum mtk_feature_support_type ft_spt_st, ft_spt_cfg; >> + struct mtk_runtime_feature *rt_feature; >> + int i, offset; >> + >> + offset = sizeof(struct feature_query); >> + for (i = 0; i < FEATURE_COUNT && offset < data_length; i++) { >> + rt_feature = data + offset; >> + offset += sizeof(*rt_feature) + le32_to_cpu(rt_feature->data_len); >> + >> + ft_spt_cfg = FIELD_GET(FEATURE_MSK, core->feature_set[i]); >> + if (ft_spt_cfg != MTK_FEATURE_MUST_BE_SUPPORTED) >> + continue; > Do MTK_FEATURE_MUST_BE_SUPPORTED appear in the host rt_features > (unlike in the device rt_features)? > Yes, in the first step of the handshake protocol, the host creates its rt_feature list with the proper support label and sends the list to the device. t7xx_parse_host_rt_data() is part of the handshake step 2, the host received the response from the device and now it will verify that the host rt_features labeled as MTK_FEATURE_MUST_BE_SUPPORTED are also supported in the device rt_features.
On Thu, 7 Apr 2022, Ricardo Martinez wrote: > From: Haijun Liu <haijun.liu@mediatek.com> > > Cross Layer DMA (CLDMA) Hardware interface (HIF) enables the control > path of Host-Modem data transfers. CLDMA HIF layer provides a common > interface to the Port Layer. > > CLDMA manages 8 independent RX/TX physical channels with data flow > control in HW queues. CLDMA uses ring buffers of General Packet > Descriptors (GPD) for TX/RX. GPDs can represent multiple or single > data buffers (DB). > > CLDMA HIF initializes GPD rings, registers ISR handlers for CLDMA > interrupts, and initializes CLDMA HW registers. > > CLDMA TX flow: > 1. Port Layer write > 2. Get DB address > 3. Configure GPD > 4. Triggering processing via HW register write > > CLDMA RX flow: > 1. CLDMA HW sends a RX "done" to host > 2. Driver starts thread to safely read GPD > 3. DB is sent to Port layer > 4. Create a new buffer for GPD ring > > Note: This patch does not enable compilation since it has dependencies > such as t7xx_pcie_mac_clear_int()/t7xx_pcie_mac_set_int() and > struct t7xx_pci_dev which are added by the core patch. > > Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> > Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > >From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> > > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > +struct cldma_tgpd { > + u8 gpd_flags; > + u8 not_used1; > + u8 not_used2; > + u8 debug_id; > + __le32 next_gpd_ptr_h; > + __le32 next_gpd_ptr_l; > + __le32 data_buff_bd_ptr_h; > + __le32 data_buff_bd_ptr_l; > + __le16 data_buff_len; > + __le16 not_used3; > +}; > + > +struct cldma_rgpd { > + u8 gpd_flags; > + u8 not_used1; > + __le16 data_allow_len; > + __le32 next_gpd_ptr_h; > + __le32 next_gpd_ptr_l; > + __le32 data_buff_bd_ptr_h; > + __le32 data_buff_bd_ptr_l; > + __le16 data_buff_len; > + u8 not_used2; > + u8 debug_id; > +}; A small additional thing... If you put next_gpd_ptr_h, next_gpd_ptr_l, data_buff_bd_ptr_h, and data_buff_bd_ptr_l into another struct inside these structs, t7xx_cldma_tgpd_set_data_ptr() and friends don't require duplicated versions for tgpd and rgpd.
On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez <ricardo.martinez@linux.intel.com> wrote: > Cross Layer DMA (CLDMA) Hardware interface (HIF) enables the control > path of Host-Modem data transfers. CLDMA HIF layer provides a common > interface to the Port Layer. > > CLDMA manages 8 independent RX/TX physical channels with data flow > control in HW queues. CLDMA uses ring buffers of General Packet > Descriptors (GPD) for TX/RX. GPDs can represent multiple or single > data buffers (DB). > > CLDMA HIF initializes GPD rings, registers ISR handlers for CLDMA > interrupts, and initializes CLDMA HW registers. > > CLDMA TX flow: > 1. Port Layer write > 2. Get DB address > 3. Configure GPD > 4. Triggering processing via HW register write > > CLDMA RX flow: > 1. CLDMA HW sends a RX "done" to host > 2. Driver starts thread to safely read GPD > 3. DB is sent to Port layer > 4. Create a new buffer for GPD ring > > Note: This patch does not enable compilation since it has dependencies > such as t7xx_pcie_mac_clear_int()/t7xx_pcie_mac_set_int() and > struct t7xx_pci_dev which are added by the core patch. > > Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> > Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> > > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> [skipped] > diff --git a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c [skipped] > +static int t7xx_cldma_gpd_rx_from_q(struct cldma_queue *queue, int budget, bool *over_budget) > +{ > + struct cldma_ctrl *md_ctrl = queue->md_ctrl; > + unsigned int hwo_polling_count = 0; > + struct t7xx_cldma_hw *hw_info; > + bool rx_not_done = true; > + unsigned long flags; > + int count = 0; > + > + hw_info = &md_ctrl->hw_info; > + > + do { > + struct cldma_request *req; > + struct cldma_rgpd *rgpd; > + struct sk_buff *skb; > + int ret; > + > + req = queue->tr_done; > + if (!req) > + return -ENODATA; > + > + rgpd = req->gpd; > + if ((rgpd->gpd_flags & GPD_FLAGS_HWO) || !req->skb) { > + dma_addr_t gpd_addr; > + > + if (!pci_device_is_present(to_pci_dev(md_ctrl->dev))) { > + dev_err(md_ctrl->dev, "PCIe Link disconnected\n"); > + return -ENODEV; > + } > + > + gpd_addr = ioread64(hw_info->ap_pdn_base + REG_CLDMA_DL_CURRENT_ADDRL_0 + > + queue->index * sizeof(u64)); > + if (req->gpd_addr == gpd_addr || hwo_polling_count++ >= 100) > + return 0; > + > + udelay(1); > + continue; > + } > + > + hwo_polling_count = 0; > + skb = req->skb; > + > + if (req->mapped_buff) { > + dma_unmap_single(md_ctrl->dev, req->mapped_buff, > + t7xx_skb_data_area_size(skb), DMA_FROM_DEVICE); > + req->mapped_buff = 0; > + } > + > + skb->len = 0; > + skb_reset_tail_pointer(skb); > + skb_put(skb, le16_to_cpu(rgpd->data_buff_len)); > + > + ret = md_ctrl->recv_skb(queue, skb); > + if (ret < 0) > + return ret; The execution flow can not be broken here even in case of error. The .recv_skb() callback consumes (frees) skb even if there is an error. But the skb field in req (struct cldma_request) will keep the skb pointer if the function returns from here. And this stale skb pointer will cause a use-after-free or double-free error. I have not dug too deeply into the CLDMA layer and can not suggest any solution. But the error handling path needs to be rechecked. > + req->skb = NULL; > + t7xx_cldma_rgpd_set_data_ptr(rgpd, 0); > + > + spin_lock_irqsave(&queue->ring_lock, flags); > + queue->tr_done = list_next_entry_circular(req, &queue->tr_ring->gpd_ring, entry); > + spin_unlock_irqrestore(&queue->ring_lock, flags); > + req = queue->rx_refill; > + > + ret = t7xx_cldma_alloc_and_map_skb(md_ctrl, req, queue->tr_ring->pkt_size); > + if (ret) > + return ret; > + > + rgpd = req->gpd; > + t7xx_cldma_rgpd_set_data_ptr(rgpd, req->mapped_buff); > + rgpd->data_buff_len = 0; > + rgpd->gpd_flags = GPD_FLAGS_IOC | GPD_FLAGS_HWO; > + > + spin_lock_irqsave(&queue->ring_lock, flags); > + queue->rx_refill = list_next_entry_circular(req, &queue->tr_ring->gpd_ring, entry); > + spin_unlock_irqrestore(&queue->ring_lock, flags); > + > + rx_not_done = ++count < budget || !need_resched(); > + } while (rx_not_done); > + > + *over_budget = true; > + return 0; > +} -- Sergey
On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez <ricardo.martinez@linux.intel.com> wrote: > Registers the t7xx device driver with the kernel. Setup all the core > components: PCIe layer, Modem Host Cross Core Interface (MHCCIF), > modem control operations, modem state machine, and build > infrastructure. > > * PCIe layer code implements driver probe and removal. > * MHCCIF provides interrupt channels to communicate events > such as handshake, PM and port enumeration. > * Modem control implements the entry point for modem init, > reset and exit. > * The modem status monitor is a state machine used by modem control > to complete initialization and stop. It is used also to propagate > exception events reported by other components. > > Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> > Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez <ricardo.martinez@linux.intel.com> wrote: > Port-proxy provides a common interface to interact with different types > of ports. Ports export their configuration via `struct t7xx_port` and > operate as defined by `struct port_ops`. > > Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> > Co-developed-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> [skipped] > diff --git a/drivers/net/wwan/t7xx/t7xx_port_proxy.c b/drivers/net/wwan/t7xx/t7xx_port_proxy.c [skipped] > +static struct t7xx_port_conf t7xx_md_port_conf[] = {}; Please spell this definition in two lines (i.e. move closing brace into next line): +static struct t7xx_port_conf t7xx_md_port_conf[] = { +}; Such spelling in this patch will help you avoid editing the line when you add the first entry in the next (control port introducing) patch: -static struct t7xx_port_conf t7xx_md_port_conf[] = {}; +static struct t7xx_port_conf t7xx_md_port_conf[] = { + { + ... + .name = "t7xx_ctrl", + }, +}; It will become as simple as: static struct t7xx_port_conf t7xx_md_port_conf[] = { + { + ... + .name = "t7xx_ctrl", + }, }; BTW, if the t7xx_md_port_conf contents are not expected to change at run-time, should this array, as well as all pointers to it, be const? [skipped] > +int t7xx_port_enqueue_skb(struct t7xx_port *port, struct sk_buff *skb) > +{ > + unsigned long flags; > + > + spin_lock_irqsave(&port->rx_wq.lock, flags); > + if (port->rx_skb_list.qlen >= port->rx_length_th) { > + spin_unlock_irqrestore(&port->rx_wq.lock, flags); Probably skb should be freed here before returning. The caller assumes that skb will be consumed even in case of error. > + return -ENOBUFS; > + } > + __skb_queue_tail(&port->rx_skb_list, skb); > + spin_unlock_irqrestore(&port->rx_wq.lock, flags); > + > + wake_up_all(&port->rx_wq); > + return 0; > +} [skipped] > +static int t7xx_port_proxy_recv_skb(struct cldma_queue *queue, struct sk_buff *skb) > +{ > + struct ccci_header *ccci_h = (struct ccci_header *)skb->data; > + struct t7xx_pci_dev *t7xx_dev = queue->md_ctrl->t7xx_dev; > + struct t7xx_fsm_ctl *ctl = t7xx_dev->md->fsm_ctl; > + struct device *dev = queue->md_ctrl->dev; > + struct t7xx_port_conf *port_conf; > + struct t7xx_port *port; > + u16 seq_num, channel; > + int ret; > + > + if (!skb) > + return -EINVAL; > + > + channel = FIELD_GET(CCCI_H_CHN_FLD, le32_to_cpu(ccci_h->status)); > + if (t7xx_fsm_get_md_state(ctl) == MD_STATE_INVALID) { > + dev_err_ratelimited(dev, "Packet drop on channel 0x%x, modem not ready\n", channel); > + goto drop_skb; > + } > + > + port = t7xx_port_proxy_find_port(t7xx_dev, queue, channel); > + if (!port) { > + dev_err_ratelimited(dev, "Packet drop on channel 0x%x, port not found\n", channel); > + goto drop_skb; > + } > + > + seq_num = t7xx_port_next_rx_seq_num(port, ccci_h); > + port_conf = port->port_conf; > + skb_pull(skb, sizeof(*ccci_h)); > + > + ret = port_conf->ops->recv_skb(port, skb); > + if (ret) { > + skb_push(skb, sizeof(*ccci_h)); Header can not be pushed back here, since the .recv_skb() callback consumes (frees) skb even in case of error. See t7xx_port_wwan_recv_skb() and my comment in t7xx_port_enqueue_skb(). Pushing the header back after failure will trigger the use-after-free error. > + return ret; > + } > + > + port->seq_nums[MTK_RX] = seq_num; The expected sequence number updated only on successful .recv_skb() exit. This will trigger the out-of-order seqno warning on a next message after a .recv_skb() failure. Is this intentional behaviour? Maybe the expected sequence number should be updated before the .recv_skb() call? Or even the sequence number update should be moved to t7xx_port_next_rx_seq_num()? > + return 0; > + > +drop_skb: > + dev_kfree_skb_any(skb); > + return 0; > +} -- Sergey
On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez <ricardo.martinez@linux.intel.com> wrote: > Control Port implements driver control messages such as modem-host > handshaking, controls port enumeration, and handles exception messages. > > The handshaking process between the driver and the modem happens during > the init sequence. The process involves the exchange of a list of > supported runtime features to make sure that modem and host are ready > to provide proper feature lists including port enumeration. Further > features can be enabled and controlled in this handshaking process. > > Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> > Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> > > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez <ricardo.martinez@linux.intel.com> wrote: > Adds AT and MBIM ports to the port proxy infrastructure. > The initialization method is responsible for creating the corresponding > ports using the WWAN framework infrastructure. The implemented WWAN port > operations are start, stop, and TX. > > Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez <ricardo.martinez@linux.intel.com> wrote: > Data Path Modem AP Interface (DPMAIF) HW layer provides HW abstraction > for the upper layer (DPMAIF HIF). It implements functions to do the HW > configuration, TX/RX control and interrupt handling. > > Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> > Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez <ricardo.martinez@linux.intel.com> wrote: > Data Path Modem AP Interface (DPMAIF) HIF layer provides methods > for initialization, ISR, control and event handling of TX/RX flows. > > DPMAIF TX > Exposes the 'dmpaif_tx_send_skb' function which can be used by the > network device to transmit packets. > The uplink data management uses a Descriptor Ring Buffer (DRB). > First DRB entry is a message type that will be followed by 1 or more > normal DRB entries. Message type DRB will hold the skb information > and each normal DRB entry holds a pointer to the skb payload. > > DPMAIF RX > The downlink buffer management uses Buffer Address Table (BAT) and > Packet Information Table (PIT) rings. > The BAT ring holds the address of skb data buffer for the HW to use, > while the PIT contains metadata about a whole network packet including > a reference to the BAT entry holding the data buffer address. > The driver reads the PIT and BAT entries written by the modem, when > reaching a threshold, the driver will reload the PIT and BAT rings. > > Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> > Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> and a small question below. > diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c > ... > +static bool t7xx_alloc_and_map_skb_info(const struct dpmaif_ctrl *dpmaif_ctrl, > + const unsigned int size, struct dpmaif_bat_skb *cur_skb) > +{ > + dma_addr_t data_bus_addr; > + struct sk_buff *skb; > + size_t data_len; > + > + skb = __dev_alloc_skb(size, GFP_KERNEL); > + if (!skb) > + return false; > + > + data_len = skb_end_pointer(skb) - skb->data; Earlier you use a nice t7xx_skb_data_area_size() function here, but now you opencode it. Is it a consequence of t7xx_common.h removing? I would even encourage you to make this function common and place it into include/linux/skbuff.h with a dedicated patch and call it something like skb_data_size(). Surprisingly, there is no such helper function in the kernel, and several other drivers will benefit from it: $ grep -rn 'skb_end_pointer(.*) [-]' drivers/net/ drivers/net/ethernet/marvell/mv643xx_eth.c:628: size = skb_end_pointer(skb) - skb->data; drivers/net/ethernet/marvell/pxa168_eth.c:322: size = skb_end_pointer(skb) - skb->data; drivers/net/ethernet/micrel/ksz884x.c:4764: if (skb_end_pointer(skb) - skb->data >= 50) { drivers/net/ethernet/netronome/nfp/ccm_mbox.c:492: undersize = max_reply_size - (skb_end_pointer(skb) - skb->data); drivers/net/ethernet/nvidia/forcedeth.c:2073: (skb_end_pointer(np->rx_skb[i].skb) - drivers/net/ethernet/nvidia/forcedeth.c:5238: (skb_end_pointer(tx_skb) - tx_skb->data), drivers/net/veth.c:767: frame_sz = skb_end_pointer(skb) - skb->head; drivers/net/wwan/t7xx/t7xx_hif_cldma.c:106: return skb_end_pointer(skb) - skb->data; drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c:160: data_len = skb_end_pointer(skb) - skb->data; > + data_bus_addr = dma_map_single(dpmaif_ctrl->dev, skb->data, data_len, DMA_FROM_DEVICE); > + if (dma_mapping_error(dpmaif_ctrl->dev, data_bus_addr)) { > + dev_err_ratelimited(dpmaif_ctrl->dev, "DMA mapping error\n"); > + dev_kfree_skb_any(skb); > + return false; > + } > + > + cur_skb->skb = skb; > + cur_skb->data_bus_addr = data_bus_addr; > + cur_skb->data_len = data_len; > + > + return true; > +} -- Sergey
On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez <ricardo.martinez@linux.intel.com> wrote: > Creates the Cross Core Modem Network Interface (CCMNI) which implements > the wwan_ops for registration with the WWAN framework, CCMNI also > implements the net_device_ops functions used by the network device. > Network device operations include open, close, start transmission, TX > timeout and change MTU. > > Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> > Co-developed-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez <ricardo.martinez@linux.intel.com> wrote: > Adds maintainers and documentation for MediaTek t7xx 5G WWAN modem > device driver. > > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Hello Ricardo, Loic, Ilpo, On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez <ricardo.martinez@linux.intel.com> wrote: > ... > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > From a WWAN framework perspective: > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> > > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> This line with "From a WWAN framework perspective" looks confusing to me. Anyone not familiar with all of the iterations will be in doubt as to whether it belongs only to Loic's review or to both of them. How about to format this block like this: > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> (WWAN framework) > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> or like this: > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> # WWAN framework > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Parentheses vs. comment sign. I saw people use both of these formats, I just do not know which is better. What do you think? -- Sergey
On Tue, 26 Apr 2022, Sergey Ryazanov wrote: > On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez > <ricardo.martinez@linux.intel.com> wrote: > > Data Path Modem AP Interface (DPMAIF) HIF layer provides methods > > for initialization, ISR, control and event handling of TX/RX flows. > > > > DPMAIF TX > > Exposes the 'dmpaif_tx_send_skb' function which can be used by the > > network device to transmit packets. > > The uplink data management uses a Descriptor Ring Buffer (DRB). > > First DRB entry is a message type that will be followed by 1 or more > > normal DRB entries. Message type DRB will hold the skb information > > and each normal DRB entry holds a pointer to the skb payload. > > > > DPMAIF RX > > The downlink buffer management uses Buffer Address Table (BAT) and > > Packet Information Table (PIT) rings. > > The BAT ring holds the address of skb data buffer for the HW to use, > > while the PIT contains metadata about a whole network packet including > > a reference to the BAT entry holding the data buffer address. > > The driver reads the PIT and BAT entries written by the modem, when > > reaching a threshold, the driver will reload the PIT and BAT rings. > > > > Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> > > Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> > > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > > > From a WWAN framework perspective: > > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> > > Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> > > and a small question below. > > > diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c > > ... > > +static bool t7xx_alloc_and_map_skb_info(const struct dpmaif_ctrl *dpmaif_ctrl, > > + const unsigned int size, struct dpmaif_bat_skb *cur_skb) > > +{ > > + dma_addr_t data_bus_addr; > > + struct sk_buff *skb; > > + size_t data_len; > > + > > + skb = __dev_alloc_skb(size, GFP_KERNEL); > > + if (!skb) > > + return false; > > + > > + data_len = skb_end_pointer(skb) - skb->data; > > Earlier you use a nice t7xx_skb_data_area_size() function here, but > now you opencode it. Is it a consequence of t7xx_common.h removing? > > I would even encourage you to make this function common and place it > into include/linux/skbuff.h with a dedicated patch and call it > something like skb_data_size(). Surprisingly, there is no such helper > function in the kernel, and several other drivers will benefit from > it: I agree other than the name. IMHO, skb_data_size sounds too much "data size" which it exactly isn't but just how large the memory area is (we already have "datalen" anyway and on language level, those two don't sound different at all). The memory area allocated may or may not have actual data in it, I suggested adding "area" into it.
On Tue, Apr 26, 2022 at 10:30 AM Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote: > On Tue, 26 Apr 2022, Sergey Ryazanov wrote: >> On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez >> <ricardo.martinez@linux.intel.com> wrote: >>> Data Path Modem AP Interface (DPMAIF) HIF layer provides methods >>> for initialization, ISR, control and event handling of TX/RX flows. >>> >>> DPMAIF TX >>> Exposes the 'dmpaif_tx_send_skb' function which can be used by the >>> network device to transmit packets. >>> The uplink data management uses a Descriptor Ring Buffer (DRB). >>> First DRB entry is a message type that will be followed by 1 or more >>> normal DRB entries. Message type DRB will hold the skb information >>> and each normal DRB entry holds a pointer to the skb payload. >>> >>> DPMAIF RX >>> The downlink buffer management uses Buffer Address Table (BAT) and >>> Packet Information Table (PIT) rings. >>> The BAT ring holds the address of skb data buffer for the HW to use, >>> while the PIT contains metadata about a whole network packet including >>> a reference to the BAT entry holding the data buffer address. >>> The driver reads the PIT and BAT entries written by the modem, when >>> reaching a threshold, the driver will reload the PIT and BAT rings. >>> >>> Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> >>> Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> >>> Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>> Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>> >>> From a WWAN framework perspective: >>> Reviewed-by: Loic Poulain <loic.poulain@linaro.org> >> >> Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> >> >> and a small question below. >> >>> diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c >>> ... >>> +static bool t7xx_alloc_and_map_skb_info(const struct dpmaif_ctrl *dpmaif_ctrl, >>> + const unsigned int size, struct dpmaif_bat_skb *cur_skb) >>> +{ >>> + dma_addr_t data_bus_addr; >>> + struct sk_buff *skb; >>> + size_t data_len; >>> + >>> + skb = __dev_alloc_skb(size, GFP_KERNEL); >>> + if (!skb) >>> + return false; >>> + >>> + data_len = skb_end_pointer(skb) - skb->data; >> >> Earlier you use a nice t7xx_skb_data_area_size() function here, but >> now you opencode it. Is it a consequence of t7xx_common.h removing? >> >> I would even encourage you to make this function common and place it >> into include/linux/skbuff.h with a dedicated patch and call it >> something like skb_data_size(). Surprisingly, there is no such helper >> function in the kernel, and several other drivers will benefit from >> it: > > I agree other than the name. IMHO, skb_data_size sounds too much "data > size" which it exactly isn't but just how large the memory area is (we > already have "datalen" anyway and on language level, those two don't sound > different at all). The memory area allocated may or may not have actual > data in it, I suggested adding "area" into it. I agree, using the "area" word in the helper name gives more clue about its purpose, thanks. -- Sergey
Hello Moises, On Tue, Apr 26, 2022 at 10:46 PM Veleta, Moises <moises.veleta@intel.com> wrote: > From: Sergey Ryazanov <ryazanov.s.a@gmail.com> > Sent: Monday, April 25, 2022 4:53 PM > To: Ricardo Martinez <ricardo.martinez@linux.intel.com> > Cc: netdev@vger.kernel.org <netdev@vger.kernel.org>; linux-wireless@vger.kernel.org <linux-wireless@vger.kernel.org>; Jakub Kicinski <kuba@kernel.org>; David Miller <davem@davemloft.net>; Johannes Berg <johannes@sipsolutions.net>; Loic Poulain <loic.poulain@linaro.org>; Kumar, M Chetan <m.chetan.kumar@intel.com>; Devegowda, Chandrashekar <chandrashekar.devegowda@intel.com>; linuxwwan <linuxwwan@intel.com>; chiranjeevi.rapolu@linux.intel.com <chiranjeevi.rapolu@linux.intel.com>; Liu, Haijun <haijun.liu@mediatek.com>; Hanania, Amir <amir.hanania@intel.com>; Andy Shevchenko <andriy.shevchenko@linux.intel.com>; Sharma, Dinesh <dinesh.sharma@intel.com>; Lee, Eliot <eliot.lee@intel.com>; Jarvinen, Ilpo Johannes <ilpo.johannes.jarvinen@intel.com>; Veleta, Moises <moises.veleta@intel.com>; Bossart, Pierre-louis <pierre-louis.bossart@intel.com>; Sethuraman, Muralidharan <muralidharan.sethuraman@intel.com>; Mishra, Soumya Prakash <soumya.prakash.mishra@intel.com>; Kancharla, Sreehari <sreehari.kancharla@intel.com>; Sahu, Madhusmita <madhusmita.sahu@intel.com> > Subject: Re: [PATCH net-next v6 04/13] net: wwan: t7xx: Add port proxy infrastructure > > On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez > <ricardo.martinez@linux.intel.com> wrote: >> Port-proxy provides a common interface to interact with different types >> of ports. Ports export their configuration via `struct t7xx_port` and >> operate as defined by `struct port_ops`. >> >> Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> >> Co-developed-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> >> Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> >> Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >> Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >> >> From a WWAN framework perspective: >> Reviewed-by: Loic Poulain <loic.poulain@linaro.org> > > [skipped] > >> +int t7xx_port_enqueue_skb(struct t7xx_port *port, struct sk_buff *skb) >> +{ >> + unsigned long flags; >> + >> + spin_lock_irqsave(&port->rx_wq.lock, flags); >> + if (port->rx_skb_list.qlen >= port->rx_length_th) { >> + spin_unlock_irqrestore(&port->rx_wq.lock, flags); > > Probably skb should be freed here before returning. The caller assumes > that skb will be consumed even in case of error. > > [MV] We do not drop port ctrl messages. We keep them and try again later. > Whereas WWAN skbs are dropped if conditions are met. I missed that the WWAN port returns no error when it drops the skb. And then I concluded that any failure to process the CCCI message should be accomplished with the skb freeing. Now the handling of CCCI messages is more clear to me. Thank you for the clarifications! To avoid similar misinterpretation in the future, I thought that the skb freeing in the WWAN port worth a comment. Something to describe that despite dropping the message, the return code is zero, indicating skb consumption. Similarly in this (t7xx_port_enqueue_skb) function. Something like: "return an error here, the caller will try again later". And maybe in t7xx_cldma_gpd_rx_from_q() near the loop break after the .skb_recv() failure test. Something like: "break message processing for now will try this message later". What do you think? >> + return -ENOBUFS; >> + } >> + __skb_queue_tail(&port->rx_skb_list, skb); >> + spin_unlock_irqrestore(&port->rx_wq.lock, flags); >> + >> + wake_up_all(&port->rx_wq); >> + return 0; >> +} > > [skipped] > >> +static int t7xx_port_proxy_recv_skb(struct cldma_queue *queue, struct sk_buff *skb) >> +{ >> + struct ccci_header *ccci_h = (struct ccci_header *)skb->data; >> + struct t7xx_pci_dev *t7xx_dev = queue->md_ctrl->t7xx_dev; >> + struct t7xx_fsm_ctl *ctl = t7xx_dev->md->fsm_ctl; >> + struct device *dev = queue->md_ctrl->dev; >> + struct t7xx_port_conf *port_conf; >> + struct t7xx_port *port; >> + u16 seq_num, channel; >> + int ret; >> + >> + if (!skb) >> + return -EINVAL; >> + >> + channel = FIELD_GET(CCCI_H_CHN_FLD, le32_to_cpu(ccci_h->status)); >> + if (t7xx_fsm_get_md_state(ctl) == MD_STATE_INVALID) { >> + dev_err_ratelimited(dev, "Packet drop on channel 0x%x, modem not ready\n", channel); >> + goto drop_skb; >> + } >> + >> + port = t7xx_port_proxy_find_port(t7xx_dev, queue, channel); >> + if (!port) { >> + dev_err_ratelimited(dev, "Packet drop on channel 0x%x, port not found\n", channel); >> + goto drop_skb; >> + } >> + >> + seq_num = t7xx_port_next_rx_seq_num(port, ccci_h); >> + port_conf = port->port_conf; >> + skb_pull(skb, sizeof(*ccci_h)); >> + >> + ret = port_conf->ops->recv_skb(port, skb); >> + if (ret) { >> + skb_push(skb, sizeof(*ccci_h)); > > Header can not be pushed back here, since the .recv_skb() callback > consumes (frees) skb even in case of error. See > t7xx_port_wwan_recv_skb() and my comment in t7xx_port_enqueue_skb(). > Pushing the header back after failure will trigger the use-after-free > error. > > [MV] Since t7xx_port_wwan_recv_skb returns 0 when dropping a skb, it skips this push operation and > will not trigger the error stated. Inside of that function an error is printed. > >> + return ret; >> + } >> + >> + port->seq_nums[MTK_RX] = seq_num; > > The expected sequence number updated only on successful .recv_skb() > exit. This will trigger the out-of-order seqno warning on a next > message after a .recv_skb() failure. Is this intentional behaviour? > > Maybe the expected sequence number should be updated before the > .recv_skb() call? Or even the sequence number update should be moved > to t7xx_port_next_rx_seq_num()? > > [MV] For t7xx_port_wwan_recv_skb, it drops skb and seq_nums is updated. > for t7xx_port_enqueue_skb, it retains skb and can be processed again later, skipping this update upon error. Now this is clear to me. Thanks. >> + return 0; >> + >> +drop_skb: >> + dev_kfree_skb_any(skb); >> + return 0; >> +}
On Wed, Apr 27, 2022 at 4:14 AM Veleta, Moises <moises.veleta@intel.com> wrote: > From: Sergey Ryazanov <ryazanov.s.a@gmail.com> > Sent: Tuesday, April 26, 2022 4:06 PM > To: Veleta, Moises <moises.veleta@intel.com> > Cc: Ricardo Martinez <ricardo.martinez@linux.intel.com>; netdev@vger.kernel.org <netdev@vger.kernel.org>; linux-wireless@vger.kernel.org <linux-wireless@vger.kernel.org>; Jakub Kicinski <kuba@kernel.org>; David Miller <davem@davemloft.net>; Johannes Berg <johannes@sipsolutions.net>; Loic Poulain <loic.poulain@linaro.org>; Kumar, M Chetan <m.chetan.kumar@intel.com>; Devegowda, Chandrashekar <chandrashekar.devegowda@intel.com>; linuxwwan <linuxwwan@intel.com>; chiranjeevi.rapolu@linux.intel.com <chiranjeevi.rapolu@linux.intel.com>; Liu, Haijun <haijun.liu@mediatek.com>; Hanania, Amir <amir.hanania@intel.com>; Andy Shevchenko <andriy.shevchenko@linux.intel.com>; Sharma, Dinesh <dinesh.sharma@intel.com>; Lee, Eliot <eliot.lee@intel.com>; Jarvinen, Ilpo Johannes <ilpo.johannes.jarvinen@intel.com>; Bossart, Pierre-louis <pierre-louis.bossart@intel.com>; Sethuraman, Muralidharan <muralidharan.sethuraman@intel.com>; Mishra, Soumya Prakash <soumya.prakash.mishra@intel.com>; Kancharla, Sreehari <sreehari.kancharla@intel.com>; Sahu, Madhusmita <madhusmita.sahu@intel.com> > Subject: Re: [PATCH net-next v6 04/13] net: wwan: t7xx: Add port proxy infrastructure > > Hello Moises, > > On Tue, Apr 26, 2022 at 10:46 PM Veleta, Moises <moises.veleta@intel.com> wrote: >> From: Sergey Ryazanov <ryazanov.s.a@gmail.com> >> Sent: Monday, April 25, 2022 4:53 PM >> To: Ricardo Martinez <ricardo.martinez@linux.intel.com> >> Cc: netdev@vger.kernel.org <netdev@vger.kernel.org>; linux-wireless@vger.kernel.org <linux-wireless@vger.kernel.org>; Jakub Kicinski <kuba@kernel.org>; David Miller <davem@davemloft.net>; Johannes Berg <johannes@sipsolutions.net>; Loic Poulain <loic.poulain@linaro.org>; Kumar, M Chetan <m.chetan.kumar@intel.com>; Devegowda, Chandrashekar <chandrashekar.devegowda@intel.com>; linuxwwan <linuxwwan@intel.com>; chiranjeevi.rapolu@linux.intel.com <chiranjeevi.rapolu@linux.intel.com>; Liu, Haijun <haijun.liu@mediatek.com>; Hanania, Amir <amir.hanania@intel.com>; Andy Shevchenko <andriy.shevchenko@linux.intel.com>; Sharma, Dinesh <dinesh.sharma@intel.com>; Lee, Eliot <eliot.lee@intel.com>; Jarvinen, Ilpo Johannes <ilpo.johannes.jarvinen@intel.com>; Veleta, Moises <moises.veleta@intel.com>; Bossart, Pierre-louis <pierre-louis.bossart@intel.com>; Sethuraman, Muralidharan <muralidharan.sethuraman@intel.com>; Mishra, Soumya Prakash <soumya.prakash.mishra@intel.com>; Kancharla, Sreehari <sreehari.kancharla@intel.com>; Sahu, Madhusmita <madhusmita.sahu@intel.com> >> Subject: Re: [PATCH net-next v6 04/13] net: wwan: t7xx: Add port proxy infrastructure >> >> On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez >> <ricardo.martinez@linux.intel.com> wrote: >>> Port-proxy provides a common interface to interact with different types >>> of ports. Ports export their configuration via `struct t7xx_port` and >>> operate as defined by `struct port_ops`. >>> >>> Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> >>> Co-developed-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> >>> Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> >>> Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>> Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>> >>> From a WWAN framework perspective: >>> Reviewed-by: Loic Poulain <loic.poulain@linaro.org> >> >> [skipped] >> >>> +int t7xx_port_enqueue_skb(struct t7xx_port *port, struct sk_buff *skb) >>> +{ >>> + unsigned long flags; >>> + >>> + spin_lock_irqsave(&port->rx_wq.lock, flags); >>> + if (port->rx_skb_list.qlen >= port->rx_length_th) { >>> + spin_unlock_irqrestore(&port->rx_wq.lock, flags); >> >> Probably skb should be freed here before returning. The caller assumes >> that skb will be consumed even in case of error. >> >> [MV] We do not drop port ctrl messages. We keep them and try again later. >> Whereas WWAN skbs are dropped if conditions are met. > > I missed that the WWAN port returns no error when it drops the skb. > And then I concluded that any failure to process the CCCI message > should be accomplished with the skb freeing. Now the handling of CCCI > messages is more clear to me. Thank you for the clarifications! > > To avoid similar misinterpretation in the future, I thought that the > skb freeing in the WWAN port worth a comment. Something to describe > that despite dropping the message, the return code is zero, indicating > skb consumption. Similarly in this (t7xx_port_enqueue_skb) function. > Something like: "return an error here, the caller will try again > later". And maybe in t7xx_cldma_gpd_rx_from_q() near the loop break > after the .skb_recv() failure test. Something like: "break message > processing for now will try this message later". > > What do you think? > > Yes, that would remove the unintended obfuscation . Unless, you think this approach is inappropriate > and should be refactored. Otherwise, I will proceed with adding those clarifying comments. > Thank you. I am Ok with the current approach. It does not contain obvious errors. It might look puzzled, but proper comments should solve this.
On Tue, 26 Apr 2022 at 02:19, Sergey Ryazanov <ryazanov.s.a@gmail.com> wrote: > > Hello Ricardo, Loic, Ilpo, > > On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez > <ricardo.martinez@linux.intel.com> wrote: > > ... > > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > > > From a WWAN framework perspective: > > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> > > > > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > > This line with "From a WWAN framework perspective" looks confusing to > me. Anyone not familiar with all of the iterations will be in doubt as > to whether it belongs only to Loic's review or to both of them. > > How about to format this block like this: > > > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> (WWAN framework) > > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > > or like this: > > > Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> > > Reviewed-by: Loic Poulain <loic.poulain@linaro.org> # WWAN framework > > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > > Parentheses vs. comment sign. I saw people use both of these formats, > I just do not know which is better. What do you think? My initial comment was to highlight that someone else should double check the network code, but it wasn't expected to end up in the commit message. Maybe simply drop this extra comment? Regards, Loic
On Wed, Apr 27, 2022 at 3:35 PM Loic Poulain <loic.poulain@linaro.org> wrote: > On Tue, 26 Apr 2022 at 02:19, Sergey Ryazanov <ryazanov.s.a@gmail.com> wrote: >> On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez >> <ricardo.martinez@linux.intel.com> wrote: >>> ... >>> Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>> Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>> >>> From a WWAN framework perspective: >>> Reviewed-by: Loic Poulain <loic.poulain@linaro.org> >>> >>> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> >> >> This line with "From a WWAN framework perspective" looks confusing to >> me. Anyone not familiar with all of the iterations will be in doubt as >> to whether it belongs only to Loic's review or to both of them. >> >> How about to format this block like this: >> >>> Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>> Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>> Reviewed-by: Loic Poulain <loic.poulain@linaro.org> (WWAN framework) >>> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> >> >> or like this: >> >>> Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>> Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>> Reviewed-by: Loic Poulain <loic.poulain@linaro.org> # WWAN framework >>> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> >> >> Parentheses vs. comment sign. I saw people use both of these formats, >> I just do not know which is better. What do you think? > > My initial comment was to highlight that someone else should double > check the network code, but it wasn't expected to end up in the commit > message. Maybe simply drop this extra comment? Yep, this drastically solves the problem with comment format :) I do not mind.
On 4/26/2022 1:00 AM, Sergey Ryazanov wrote: > On Tue, Apr 26, 2022 at 10:30 AM Ilpo Järvinen > <ilpo.jarvinen@linux.intel.com> wrote: >> On Tue, 26 Apr 2022, Sergey Ryazanov wrote: >>> On Fri, Apr 8, 2022 at 1:37 AM Ricardo Martinez >>> <ricardo.martinez@linux.intel.com> wrote: >>>> Data Path Modem AP Interface (DPMAIF) HIF layer provides methods >>>> for initialization, ISR, control and event handling of TX/RX flows. >>>> >>>> DPMAIF TX >>>> Exposes the 'dmpaif_tx_send_skb' function which can be used by the >>>> network device to transmit packets. >>>> The uplink data management uses a Descriptor Ring Buffer (DRB). >>>> First DRB entry is a message type that will be followed by 1 or more >>>> normal DRB entries. Message type DRB will hold the skb information >>>> and each normal DRB entry holds a pointer to the skb payload. >>>> >>>> DPMAIF RX >>>> The downlink buffer management uses Buffer Address Table (BAT) and >>>> Packet Information Table (PIT) rings. >>>> The BAT ring holds the address of skb data buffer for the HW to use, >>>> while the PIT contains metadata about a whole network packet including >>>> a reference to the BAT entry holding the data buffer address. >>>> The driver reads the PIT and BAT entries written by the modem, when >>>> reaching a threshold, the driver will reload the PIT and BAT rings. >>>> >>>> Signed-off-by: Haijun Liu <haijun.liu@mediatek.com> >>>> Signed-off-by: Chandrashekar Devegowda <chandrashekar.devegowda@intel.com> >>>> Co-developed-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>>> Signed-off-by: Ricardo Martinez <ricardo.martinez@linux.intel.com> >>>> >>>> From a WWAN framework perspective: >>>> Reviewed-by: Loic Poulain <loic.poulain@linaro.org> >>> Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com> >>> >>> and a small question below. >>> >>>> diff --git a/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c b/drivers/net/wwan/t7xx/t7xx_hif_dpmaif_rx.c >>>> ... >>>> +static bool t7xx_alloc_and_map_skb_info(const struct dpmaif_ctrl *dpmaif_ctrl, >>>> + const unsigned int size, struct dpmaif_bat_skb *cur_skb) >>>> +{ >>>> + dma_addr_t data_bus_addr; >>>> + struct sk_buff *skb; >>>> + size_t data_len; >>>> + >>>> + skb = __dev_alloc_skb(size, GFP_KERNEL); >>>> + if (!skb) >>>> + return false; >>>> + >>>> + data_len = skb_end_pointer(skb) - skb->data; >>> Earlier you use a nice t7xx_skb_data_area_size() function here, but >>> now you opencode it. Is it a consequence of t7xx_common.h removing? >>> >>> I would even encourage you to make this function common and place it >>> into include/linux/skbuff.h with a dedicated patch and call it >>> something like skb_data_size(). Surprisingly, there is no such helper >>> function in the kernel, and several other drivers will benefit from >>> it: >> I agree other than the name. IMHO, skb_data_size sounds too much "data >> size" which it exactly isn't but just how large the memory area is (we >> already have "datalen" anyway and on language level, those two don't sound >> different at all). The memory area allocated may or may not have actual >> data in it, I suggested adding "area" into it. > I agree, using the "area" word in the helper name gives more clue > about its purpose, thanks. > Sounds good. I'll add a patch to introduce skb_data_area_size(), I'm not planning to update other drivers to use it, at least in this series. Please let me know if you think otherwise.